We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
6.4.2
Partial<Location>
initialEntries
import { createMemoryRouter } from 'react-router-dom'; const router = createMemoryRouter([], { initialEntries: [{ pathname: '/foo', state: { myState: 'bar' } }], });
The code type-checks and works as normal, where the state is accessible in the components with useLocation.
useLocation
The code does not type-check but works as normal, where the state is accessible in the components with useLocation. The type error is:
TS2322: Type '{ pathname: string; state: { myState: string; }; }' is not assignable to type 'string'.
This seems to be because initialEntries of createMemoryRouter is typed as string[] rather than InitialEntry[] which is what createMemoryHistory uses and initialEntries is passed on to.
string[]
InitialEntry[]
The text was updated successfully, but these errors were encountered:
The documentation also seems to show the type as InitialEntry[].
Sorry, something went wrong.
Thanks! Just merged a fix for this in #9498, should be out in a 6.4.3-pre.1 hopefully today and then a stable 6.4.3 later this week or next
6.4.3-pre.1
Thanks a lot @brophdawg11! I appreciate it 👍
Successfully merging a pull request may close this issue.
What version of React Router are you using?
6.4.2
Steps to Reproduce
Partial<Location>
object ininitialEntries
when creating a memory router:Expected Behavior
The code type-checks and works as normal, where the state is accessible in the components with
useLocation
.Actual Behavior
The code does not type-check but works as normal, where the state is accessible in the components with
useLocation
.The type error is:
This seems to be because initialEntries of createMemoryRouter is typed as
string[]
rather thanInitialEntry[]
which is what createMemoryHistory uses andinitialEntries
is passed on to.The text was updated successfully, but these errors were encountered: