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

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.
主站蜘蛛池模板: 隆德县| 岳普湖县| 拉孜县| 镇赉县| 宝山区| 平顺县| 双柏县| 松滋市| 哈尔滨市| 循化| 永清县| 资中县| 彰武县| 册亨县| 桐庐县| 西畴县| 南陵县| 建宁县| 江门市| 渭源县| 中阳县| 湖南省| 庄浪县| 丹凤县| 大城县| 阳原县| 长兴县| 扎鲁特旗| 徐州市| 新竹县| 永和县| 彩票| 永新县| 贵溪市| 漳浦县| 乌兰察布市| 黄山市| 华安县| 连山| 麻江县| 讷河市|