Skip to content

feat(react): Add support for React Router createMemoryRouter #14854

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

Merged
merged 8 commits into from
Jan 10, 2025

Conversation

onurtemizkan
Copy link
Collaborator

@onurtemizkan onurtemizkan commented Dec 30, 2024

Ref: #14814

I was not able to properly distinguish between the instances of BrowserRouter and MemoryRouter. However, using initialEntries with BrowserRouter should break TypeScript where it's available. We can alternatively export a wrapper specific to MemoryRouter if that makes better sense.

@onurtemizkan onurtemizkan force-pushed the onur/react-initial-entries branch from e479bde to 9f1cd47 Compare December 30, 2024 10:38
Copy link

codecov bot commented Dec 30, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
254 1 253 8
View the top 1 failed tests by shortest run time
transactions.test.ts Captures a pageload transaction
Stack Traces | 1.19s run time
transactions.test.ts:4:5 Captures a pageload transaction

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@onurtemizkan onurtemizkan force-pushed the onur/react-initial-entries branch from 9f1cd47 to 6a7c1a0 Compare January 1, 2025 11:50
@onurtemizkan onurtemizkan marked this pull request as ready for review January 1, 2025 12:33
@lforst
Copy link
Member

lforst commented Jan 7, 2025

We can alternatively export a wrapper specific to MemoryRouter if that makes better sense.

I actually think this idea isn't too bad. 🤔 Would it be a lot of effort?

@onurtemizkan onurtemizkan force-pushed the onur/react-initial-entries branch from 6a7c1a0 to 358452f Compare January 9, 2025 16:17
@onurtemizkan onurtemizkan force-pushed the onur/react-initial-entries branch from 54cb551 to ea95f26 Compare January 9, 2025 17:01
@onurtemizkan
Copy link
Collaborator Author

@lforst - Updated the PR to export wrapCreateMemoryRouterV6 and wrapCreateMemoryRouterV7. I'll update the docs, and backport to v8 if this looks good.

@lforst lforst changed the title feat(react): Use initialEntries in wrapped routers. feat(react): Add support for React Router createMemoryRouter Jan 10, 2025
Copy link
Member

@lforst lforst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the liberty to do 2 functions instead of the boolean arg. I have seen that pattern go bad very quickly.

Otherwise looks great to me! We shouldn't forget to add docs.

@lforst lforst merged commit 8e53415 into develop Jan 10, 2025
134 checks passed
@lforst lforst deleted the onur/react-initial-entries branch January 10, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants