-
Notifications
You must be signed in to change notification settings - Fork 114
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
Clicking on the link adds a search parameter. And it crashes when the page is refreshed. #485
Comments
I created the file named _layout.jsx in the folder named P and put the following code.
In addition, I made my Root layout file like this.
It then started working fine, but why is this necessary? I could not find the correct information in the documentation. Did I make a mistake or is this a bug? |
Hey everyone! I have the same issue :( -.and.10.more.pages.-.Personal.-.Microsoft.Edge.2023-05-01.01-28-58_Trim.mp4But at the same time I have an addition. That the error occurs only when we pass one parameter. Bad: router.push({
pathname: '/cuisine/[path]/[foodPointId]/[...foodPoint]',
params: {
path: 'cafe',
foodPointId: 470,
foodPoint: [107], // Single param for [...foodPoint]
},
}); Good: router.push({
pathname: '/cuisine/[path]/[foodPointId]/[...foodPoint]',
params: {
path: 'cafe',
foodPointId: 470,
foodPoint: [107, 'priceAsc'], // 2> params for [...foodPoint]
},
}); |
Although it does not throw the error on refresh, I still get the same issue when navigating to a different route and pressing the back button in the browser. Aside from this, the extra Seems like a bug to me, still, or some mechanic/nuance that's not entirely clear from the documentation. |
OP is having an issue due to misuse of the rest parameter. When you use |
Summary
Screen.Recording.2023-04-11.at.22.05.35.mov
If I change the name of the rest in the code sample, this time it adds a parameter with that name.
And when I refresh the page it doesn't work. When I delete the search parameter, which I don't know why it added, the page continues to work.
All I do is redirect to p/1 or p/2 as href.
Forwarding states
app
/P/1 => /P/1?rest=1
/P/2 => /P/2?rest=2
/P/test-product-name/1 => /P/test-product-name/1?rest=test-product-name&rest=1
The situation I want
P/1 => P/1
P/2 => P/2
/P/test-product-name/1 => /P/test-product-name/1
Minimal reproducible example
App Folder
Root Layout
ProductCard Component
The text was updated successfully, but these errors were encountered: