You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello Everyone,
I ran into a small issue with the useParams() hook. I wanted to do the following in one of my projects.
/products/categories/:food -> Display Products component with food subsection
/products -> Display the Products component without any subsections
Both the routes are pointing to the same component. Here's the issue.
Step 1: I'm navigating to the 1st URL (/products/categories/apple). useParams hook returns the following object -> {"0":"apple","category":"apple"}.
Step 2: I am navigating to the 2nd URL (/products). Here useParams hook is pointing to the same object {"0":"apple","category":"apple"} and not {}.
I have created a codesandbox which illustrates this issue.
@molefrog Could there be another related issue still not fixed here? I have updated the Codesandbox from @khavin with a page parameter for the sake of testing.
Hello Everyone,
I ran into a small issue with the useParams() hook. I wanted to do the following in one of my projects.
Both the routes are pointing to the same component. Here's the issue.
Step 1: I'm navigating to the 1st URL (/products/categories/apple). useParams hook returns the following object ->
{"0":"apple","category":"apple"}
.Step 2: I am navigating to the 2nd URL (/products). Here useParams hook is pointing to the same object
{"0":"apple","category":"apple"}
and not{}
.I have created a codesandbox which illustrates this issue.
Codesandbox Link
There are three links. Click the links one by one and see how the params update. Let me know if this is the expected behavior.
The text was updated successfully, but these errors were encountered: