Skip to content

Devtools cause hydration error #1726

@PepijnSenders

Description

@PepijnSenders

Describe the bug
The devtools cause a hydration error because the state values that depend on localStorage are not equal to the state values returned from the server. We should make sure that these state values are only set after the client has mounted, so on a useEffect() and not a direct call to localStorage.

https://github.com/tannerlinsley/react-query/blob/master/src/devtools/devtools.tsx#L337

To Reproduce
Add dev client, have something in localStorage, refresh.

Expected behavior
No hydration error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions