question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nested custom routing

See original GitHub issue

Using custom routing nested Route:

App.js

      <Router>
            <div className="App-menu">
                <Link to='/en/works'>Works</Link>
                <Link to='/en/about'>About</Link>
                <Link to='/en/events'>Events</Link>
            </div>
            <div className="App-right">
               <Switch>
                <Route path="/" exact render={() => null} />
                <Route path={`/:lang/about`} render={() => <About lang={lang} />} />
                <Route path={`/:lang/events`} render={() => <Events lang={lang} />} />
                <Route path={`/:lang/works`} render={() => <WorkList lang={lang} />} />
              </Switch>
            </div>
      </Router>

WorkList.js

 <div>     
   <div className="works-menu">
         <Link to={`/en/works/work1`}>work1</Link>
         <Link to={`/en/works/work2`}>work2</Link>
         <Link to={`/en/works/work3`}>work3</Link>
   </div>
   <Route path={`/:lang/works/:name`} render={() => <Work lang={lang} />} />
</div>

It works if I go directly (full page refresh) to /en/works/work1. However I get an error if I do a menu click on one of <Link to={'/en/works/work1'}>work1</Link>.

I have all the route in my static config:

        return [
            {
                path: '/',
            },
            {
                path: `/en/works/work1`,
                getProps: () => ({
                        data: work1,
                }),
            },       
            etc..
        ];

Also tried having children property in static config. The same output: Warning: getRouteProps could not find any props for route: /en/works/stone-water-sting. Either you are missing a getProps function for this route in your static.config.js or you are using the getRouteProps HOC when you don't need to.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tannerlinsleycommented, Jan 22, 2018

Upgrade to the patch I just released (4.8.5) and it should be fixed 😃

0reactions
tannerlinsleycommented, Jan 22, 2018

Awesome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Guide to Nested Routes with React Router - ui.dev
In this comprehensive, up-to-date guide, you'll learn everything you need to know about creating nested routes with React Router.
Read more >
rails routes and custom routing for nested resource
For several projects I need something to simplify my routes to remove the controller name for one of the most important routes.
Read more >
Nested Routing in react-router-dom - DEV Community ‍ ‍
Nested routing is the act of "burying" routes inside each other. ... Lets start by creating a custom component to store the routing...
Read more >
Adding Nested Routes - Tutorial - Ember Guides
The index nested route is shown by default when the user visits the rentals ... route's path by specifying this.route('index', { path: '/custom-path'})...
Read more >
Nested routings and Custom Data - SAP Community
Hi, I am working and testing different solutions with Nested Routings. For normal operations in a routing I can add Custom Data for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found