Next.js Discord

Discord Forum

RTK query with StrictMode Nextjs.

Unanswered
Pointer posted this in #help-forum
Open in Discord
Original message was deleted.

7 Replies

Dunker
What is problem
@Dunker What is problem
Pointer
State posts is updated twice and the data is rendered duplicate in DOM.
@Pointer State posts is updated twice and the data is rendered duplicate in DOM.
Dunker
can be related with ln:33
[...prev, ...posts.data]
Giant panda
That's not a bug, it's intended behavior with React Strict Mode and indicates you have a bug. In your case you already have the posts object from the query and you should not add it to another state inside the component.
@Giant panda That's not a bug, it's intended behavior with React Strict Mode and indicates you have a bug. In your case you already have the `posts` object from the query and you *should not* add it to another state inside the component.
Pointer
in this line 33, i need add it to state to load more data. Normaly, React Strict Mode will log from debugger, but i see it log from component twice.
this is my next.config