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

Allow to set router's futures #76

Open
artaommahe opened this issue Nov 11, 2024 · 6 comments
Open

Allow to set router's futures #76

artaommahe opened this issue Nov 11, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@artaommahe
Copy link

artaommahe commented Nov 11, 2024

Is your feature request related to a problem? Please describe.
Since version 6.28.0 react-router-dom spams a lot of warnings about enabling v7 futures in console. storybook-addon-remix-react-router provides no way so set them

Describe the solution you'd like
Add futures object to reactRouter storybook options and pass it to the react-router-dom.

Describe alternatives you've considered

-

Additional context
https://reactrouter.com/en/6.27.0/upgrading/future#update-to-latest-v6x
remix-run/react-router#12245

@artaommahe artaommahe added the enhancement New feature or request label Nov 11, 2024
@JesusTheHun
Copy link
Owner

@artaommahe Can you try the canary version ?

npm i [email protected]

@artaommahe
Copy link
Author

@JesusTheHun just checked - the change in this version covers only RouterProvider`s future field, but doesn't cover createBrowserRouter's future field, that has much more flags to be set to suppress those annoying warnings. Our current futures setup for the app to suppress all warnings looks like this

const router = createBrowserRouter([/* routes list */], {
    future: {
      v7_relativeSplatPath: true,
      v7_fetcherPersist: true,
      v7_normalizeFormMethod: true,
      v7_partialHydration: true,
      v7_skipActionErrorRevalidation: true,
    },
});

<RouterProvider
  router={router}
  future={{
    v7_startTransition: true,
  }}
/>

also the typings for the implemented RouterParameters.future are a bit wrong. If that field is used with a RouterProvider then the type should be the same as RouterProviderProps.future?: Partial<Pick<FutureConfig, "v7_startTransition">>; from the react-router

@JesusTheHun
Copy link
Owner

Hey @artaommahe 👋 can you give a try to the latest canary please ?

@artaommahe
Copy link
Author

@JesusTheHun now it works properly for futures passed to the createBrowserRouter, but doesn't support futures passed to the RouterProvider.future 😅 , like v7_startTransition. So most warnings are finally gone, except one related to v7_startTransition

@JesusTheHun
Copy link
Owner

@artaommahe Oh ok. They gave the same name to two different interfaces.
I've tried locally and it works just fine now :)

@artaommahe
Copy link
Author

@JesusTheHun we've already updated to v7 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants