When I try to use react-beautiful-dnd
with next.js
(or in general with server side rendering), after reorder items and refresh the page I get this error:
react-dom.development.js:88 Warning: Prop `data-rbd-draggable-context-id` did not match. Server: "1" Client: "0"
And this (that depends on the first one):
react-beautiful-dnd.esm.js:39 react-beautiful-dndA setup problem was encountered.> Invariant failed: Draggable[id: 1]: Unable to find drag handle
I try to use resetServerContext()
to reset the server context counter, but it doesn't work as expected.
After some test i found a solution. Just call
resetServerContext()
server side.As an example, in a
next.js
page just call it ingetServerSideProps