-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
[Bug]: generatePath removes a parameter if it's value is 0 (number) #10593
Comments
Fixed by #10612 and will be included in the next release |
🤖 Hello there, We just published version Thanks! |
thanks, it works |
🤖 Hello there, We just published version Thanks! |
What version of React Router are you using?
6.12.1
Steps to Reproduce
generatePath('/product/:id', { id: 0 })
returns/products
(expected:/products/0
)I know it's kinda not valid to pass 0 as a number, BUT it worked in 6.3.0 and before (so it's a regression). Also passing any other number works ok:
generatePath('/product/:id', { id: 1 })
returns/products/1
generatePath('/product/:id', { id: 2 })
returns/products/2
of course, passing 0 as string works as well
generatePath('/product/:id', { id: '0' })
returns/products/0
The fact that it works for other numbers could cause issues, because developers might use it, and then suddenly when the value is 0 it stops to work.
Expected Behavior
generatePath('/product/:id', { id: 0 })
-> /products/0Actual Behavior
generatePath('/product/:id', { id: 0 })
-> /productsThe text was updated successfully, but these errors were encountered: