admin管理员组文章数量:1287632
I see in the React Router docs that you pass into ponents the match
prop, and you can call match.url
, but you never seem to actually pass in anything to the ponent. So what exactly is match and where are you getting it from?
I see in the React Router docs that you pass into ponents the match
prop, and you can call match.url
, but you never seem to actually pass in anything to the ponent. So what exactly is match and where are you getting it from?
2 Answers
Reset to default 3Hope this helps: https://reacttraining./react-router/web/api/match
You get match
in the props, usually when your ponent is called by a Route you will get it, and you can pass it down to other ponents as regular props to extract or use the information.
location
is also very useful when interacting with react-router. I usually use match to do rendering and redirecting depending on the isExact
flag, and location to have the actual URL that the browser has.
See match() is pure JavaScript's String property. So if match is used in JSX, then react also made it's custom property match
so that it does not conflict with main match()
and it is global object for React Router.
I have faced this issue and worked out knowing that don't need to worry that it should be passed in props or state. In fact it is custom property in JSX which does not conflict with actual String.prototype's property.
So without messing your head, just think it as of match()
property that is from global Object specially used in React Router
本文标签: javascriptWhat exactly is matchurl in React RouterStack Overflow
版权声明:本文标题:javascript - What exactly is match.url in React Router? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741249480a2365522.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论