This is more of a poll than anything else.
When working with React, do you pass parameters when routing by chaining them to the URL
or as state
?
Is there even a best practice to follow for this?
Params:
navigate('/edit/${user.id}')`
State:
navigate('/edit', { state : {id :user.id} } )
For me, it depends on the action I am trying to do.
If I want a single route with some dynamic information, such as chat id, which I don't want to be stored in the URL, I prefer setting it in the history state.
But, for REST actions (edit/add and such on), I prefer chaining the id
in the URL itself. It has some benefits. The primary one I see is that you can copy the URL, paste it somewhere else (different computer/browser), and you'll still access the same page with the details about the id
you chained.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With