Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTKQ: Warning with NextJs #1173

Closed
OscarVelandia opened this issue Jun 12, 2021 · 1 comment · Fixed by #1319
Closed

RTKQ: Warning with NextJs #1173

OscarVelandia opened this issue Jun 12, 2021 · 1 comment · Fixed by #1319
Labels
bug Something isn't working rtk-query

Comments

@OscarVelandia
Copy link

OscarVelandia commented Jun 12, 2021

Hi, with NextJs I have this warning

Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes.

But with the "@rtk-incubator/rtk-query": "^0.3.0" it doesn't happens.

My dependencies are:

   "@reduxjs/toolkit": "^1.6.0",
    "next": "10.2.3",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-redux": "^7.2.4",

And my _app.tsx configuration is:

import '../styles/globals.scss';
import type { AppProps } from 'next/app';
import { Provider } from 'react-redux';
import { store } from '@store';

function MyApp({ Component, pageProps }: AppProps) {
  return (
    <Provider store={store}>
      <Component {...pageProps} />
      <div id="modal-root" />
    </Provider>
  );
}
export default MyApp;
@markerikson
Copy link
Collaborator

This warning is unfortunately React being over-zealous. It warns you about any use of useLayoutEffect in a server environment, to try to let you know that the effect won't actually get run:

facebook/react#14927

We do appear to have one use of useLayoutEffect in this codebase. We'll have to see if we can tweak it to use React-Redux's useIsomorphicLayoutEffect instead, to avoid this issue.

@markerikson markerikson added the bug Something isn't working label Jun 12, 2021
@markerikson markerikson added this to the 1.7 milestone Jun 12, 2021
@markerikson markerikson removed this from the 1.7 milestone Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rtk-query
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants