Make the outer layout aware of the current route in react static

141 Views Asked by At

My app has a structure like this:

const App = () => (
    <Router>
      <Layout>
        <Routes />
      </Layout>
    </Router>
)

However, I would like to make the layout depend on the type of page that is loaded.

I know that there is a this.props.location inside the rendered routes, but I cannot access it from the outside.

I read about lifting state up, but I don't know whether that's possible with the <Routes /> component.

How can I get the current route in my Layout component?

0

There are 0 best solutions below