react-router-v5

React Router 5.1 - useLocation hook - determine past locations

白昼怎懂夜的黑 提交于 2020-05-17 06:51:00
问题 According to React Router 5.1 documentation it should be possible to see "where the app is now, where you want it to go, or even where it was". In my app I need to see "where it was" - what locations I have visited before landing at a specific location. More precisely; I wish to find a prevoious location matching a certain pattern. That location might be two or three locations ago. However - I cannot figure out how to perform this. What is the best and recommended approach to achieve this?

React Router 5.1 - useLocation hook - determine past locations

我的未来我决定 提交于 2020-05-17 06:50:04
问题 According to React Router 5.1 documentation it should be possible to see "where the app is now, where you want it to go, or even where it was". In my app I need to see "where it was" - what locations I have visited before landing at a specific location. More precisely; I wish to find a prevoious location matching a certain pattern. That location might be two or three locations ago. However - I cannot figure out how to perform this. What is the best and recommended approach to achieve this?

Proper way of handling conditional component render depending on route?

一曲冷凌霜 提交于 2019-12-07 03:04:19
问题 I searched a lot on the Web and SO, asked in reactiflux chat, but didn't found a clean and non-hack-looking way of rendering some component depending of route/path. Let's say I have the <Header /> which should be shown on some pages and should be hidden on other ones. For sure I can use this string in Header component if (props.location.pathname.indexOf('/pageWithoutAHeader') > -1) return null That's totally fine, if /pageWithoutAHeader is the unique. If I need same functionality for 5 pages

Proper way of handling conditional component render depending on route?

丶灬走出姿态 提交于 2019-12-05 07:23:00
I searched a lot on the Web and SO, asked in reactiflux chat, but didn't found a clean and non-hack-looking way of rendering some component depending of route/path. Let's say I have the <Header /> which should be shown on some pages and should be hidden on other ones. For sure I can use this string in Header component if (props.location.pathname.indexOf('/pageWithoutAHeader') > -1) return null That's totally fine, if /pageWithoutAHeader is the unique. If I need same functionality for 5 pages it become this: if (props.location.pathname.indexOf('/pageWithoutAHeader1') > -1) return null if (props