1

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?

dance2die
  • 35,807
  • 39
  • 131
  • 194
Xiphias
  • 4,468
  • 4
  • 28
  • 51
  • Hi, have you tried using Routes with children render prop like this https://stackoverflow.com/questions/54055652/does-routes-break-hrm-in-react-static? – Evgeny Timoshenko Jan 05 '19 at 19:53

0 Answers0