zilch / type-route

The flexible, type safe routing library.
https://type-route.zilch.dev
MIT License
424 stars 15 forks source link

For react 18, <RouteProvider> needs to be above react's <StrictMode> #102

Closed awdyson closed 2 years ago

awdyson commented 2 years ago

If it isn't, URL updates (including route().link) won't trigger view updates. Not sure if this is a documentation change issue or a revamp.

Here's some working code though:

const root = createRoot(document.getElementById('app') as HTMLElement);

function App() {
  return (
    <RouteProvider>
      <StrictMode>
        // other providers and content
      </StrictMode>
    </RouteProvider>
  );
}

root.render(<App />);

If I were you, I'd leave this open for a while, even if you update the docs. Issues are generally the first place I look if something is funky 😛

Also, this seems ominous... https://github.com/facebook/react/issues/21674#issuecomment-990707432

bradenhs commented 2 years ago

Thanks for bringing this up! I did some testing on experimental builds of react a while back but haven't tried out the 18 release yet with Type Route. I'll do that soon.

bradenhs commented 2 years ago

This should be fixed in https://github.com/typehero/type-route/releases/tag/0.7.0. Thanks for the bug report!