官术网_书友最值得收藏!

The strict prop

When the <Route> path has a trailing slash, and you would like to match this path, including the trailing slash, with the browser's URL, then include the strict prop. For example, after changing the <Route> path from '/dashboard' to '/dashboard/', the <Route> component would still match the URL path without the trailing slash. In other words, '/dashboard' would match the <Route> component with the '/dashboard/' path.

However, after adding the strict prop, React-Router ensures that <Route> matches only if the URL has a trailing slash:

<Route
path="/dashboard/"
component={DashboardComponent}
strict
/>

With this <Route> configuration in place, the '/dashboard' path would not match. However, when you add a trailing slash to the URL, as in '/dashboard/', the <Route> component with a strict prop will match and the DashboardComponent would be rendered.

Please note, if you mention additional URL segments, then it would still match the path prop mentioned in the <Route> component. For example, if the URL path is '/dashboard/123', it would match the  '/dashboard/' path with a  <Route> component that has the strict prop. To match a path including the additional URL segments, you can specify the exact prop along with the strict prop.
主站蜘蛛池模板: 即墨市| 永昌县| 汽车| 伊金霍洛旗| 伊金霍洛旗| 正定县| 嘉定区| 普格县| 潜山县| 浑源县| 将乐县| 麦盖提县| 仁化县| 柯坪县| 万荣县| 乌兰浩特市| 荣昌县| 萨嘎县| 阿图什市| 班玛县| 湄潭县| 慈利县| 青冈县| 康平县| 长岭县| 穆棱市| 罗江县| 舟曲县| 登封市| 哈尔滨市| 定结县| 榆社县| 胶南市| 蚌埠市| 保靖县| 利川市| 宁国市| 阆中市| 边坝县| 永昌县| 达孜县|