Fixes #1265 Updated example for react-router v6.4#1266
Fixes #1265 Updated example for react-router v6.4#1266maruhgar wants to merge 1 commit intotesting-library:mainfrom
Conversation
✅ Deploy Preview for testing-library ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
| --- | ||
|
|
||
| This example demonstrates React Router v6. For previous versions see below. | ||
| This example demonstrates React Router v6.4 and above. For previous versions see below. |
There was a problem hiding this comment.
I'm not very familiar with this, but I assume createBrowserRouter is added in v6.4?
| } from 'react-router-dom'; | ||
|
|
||
| // Method to introduce an artificial delay | ||
| export function sleep(n = 500) { |
There was a problem hiding this comment.
Could you clean this example up please?
sleep doesn't really add any value here, it's just introduces clutter.
There was a problem hiding this comment.
Actually this is a modified form of the example in react router examples source code I wanted this to be close to the original doc and hence left it.
| await sleep(); | ||
| let formData = await request.formData(); | ||
| let name = formData.get('name'); | ||
| console.log(name); |
| } | ||
|
|
||
| // Action to get user input | ||
| export async function aboutAction({ request }) { |
There was a problem hiding this comment.
I think this can also be left out, or there should be a test that verifies its behavior.
| expect(screen.getByTestId('location-display')).toHaveTextContent(route); | ||
| }); | ||
| ``` | ||
| Refer to [this working example](https://stackblitz.com/edit/vitejs-vite-dnutcg?file=src%2FApp.test.jsx,src%2FApp.jsx) |
There was a problem hiding this comment.
Because other examples don't have a stackblitz I was thinking on removing this?
There was a problem hiding this comment.
Te reason for having that was, I couldn't get other examples to run without making code changes
|
Would be nice to have updated examples for react router on the website. |
|
@vhakulinen Feel free to move forwards with this PR/create a different PR :) |
|
Unfortunately, I don't have the bandwidth to do that at the moment. (I hope my comment didn't come off as rude, I really appreciate all the work done by you all) |
On the contrary, I want this PR to be pushed also. |
Added a section with an example to use
testing-librarywithreact-routerv6.4and above