Two different export createBrowserRouter when Page is lazy route using recoil to update store will show fail message #10829
-
My example code is here Example Repo Package version is
This export no show warning message But this one will show "Matched leaf route at location "/about" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page." Can anyone tell me the difference? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You shouldn't be creating your data router inside of the react render lifecycle, otherwise it will be destroyed and recreated on each render. Instead, it should be created as a singleton outside of React and passed to |
Beta Was this translation helpful? Give feedback.
You shouldn't be creating your data router inside of the react render lifecycle, otherwise it will be destroyed and recreated on each render. Instead, it should be created as a singleton outside of React and passed to
RouterProvider
. There's an example of this setup in the docs.