Skip to content
Advertisement

Tag: react-router

Organizing React routes into separate components

I’m trying to find a way to organize my routes to assist the dev who might be taking over my work in the future. I thought of separating my <Route /> entries into separate components and then just load those into a main component similar to how users are assigned groups. The issue is that when using more than one

‘history’, no-restricted-globals, and window.history

So I was running into an issue with React where if I tried to use ‘history’, my code wouldn’t run telling me it’s an ‘unexpected use of history no-restricted-global’. I turned to StackOverflow in order to get help and surprisingly, I was able to find an answer to the issue that I was dealing with. The fix that another use

How to get pathname in the layout file in gatsby

I am working with gasby and here the main file is always layout.js which is the parent of them all. Since it is a parent file then how can I get a location props this.props.location.pathname inside it? Here is my layout component Answer As stated in the Gatsby docs: In v1, the layout component had access to history, location, and

Advertisement