You won’t have access to those same props if you go directly to that /courses url in your browser That’s because you will only have access to those props by clicking on Link. Passing props through the component is primarily there to pass props related to the navigation history. This is what props passing through looks like in the docs: Let’s take a look at how we can pass objects! Passing props through Link’s state There’s an excellent example of URL parameters in the doc: īut these URL parameters are limited to only strings. For example if you’d want to help your friend finding out how to pass params with react-router, you will be able to share your search results with him: /courses?q=how+to+pass+params+through+link+in+react+router Passing props through URL params is very convenient when you want a shareable url. If you’re not and you find that something is not working, let me know about it, give me your react version and react-router version on Twitter and I’ll see if I can help. I’ll assume that you’re using hooks and v5 or v6 of react router.
0 Comments
Leave a Reply. |