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.

NavBar/Footer are hidden on dynamic routes in production

See original GitHub issue

I have this Paths file:

import {
  Register,
} from '../components/pages/'
import StaticRoutes from 'react-static-routes'

const Paths = (
  <Switch>
    <Route exact path="/registro" component={Register} />
    <StaticRoutes />
  </Switch>

export default Paths

My Pages index:

import universal from 'react-universal-component'

const Login = universal(import('./auth/login/'))
const Register = universal(import('./auth/register/'))

export {
  Register
}

And my App.js

const App = () => (
  <Provider store={store}>
    <Router>
      <ThemeProvider theme={theme}>
        <div className="content">
          <NavBar />
          <div className="emp-container">{Paths}</div>
          <Footer />
          <Modal />
        </div>
      </ThemeProvider>
    </Router>
  </Provider>
)

export default hot(module)(App)

In localhost all work fine. But in production (react-static build), when i navigate to dynamic route, only render the <div className="emp-container">{Paths}</div> and <NavBar />, <Footer />, <Modal /> dont are rendered (It do not appear in html inspector). With static routes all works fine.

Versions:

"react": "^16.0.0",
"react-static": "^5.9.7",

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tannerlinsleycommented, Sep 7, 2018

withRouteData and RouteData only need to be inside the <Router> component. If all you are looking for is the history object though, you can get it with the withRouter HOC.

import { withRouter } from 'react-static' // or react-router

withRouter(({ history }) => (
  // use history
))
0reactions
luisfuertescommented, Sep 28, 2018

@tannerlinsley only in withRouteData connected components? Or in all files, like redux actions file?

You can try it in: https://github.com/luisfuertes/react-static-demo

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - React Router, hide Nav & footer on certain pages ...
Hi you can do it by having a state that only when the state is true the nav and footer will render: function...
Read more >
Dynamic Navigation in Next.js – How to Render Nav-Items ...
I've lately been noticing a pattern in React applications: developers protect certain routes on a web app from unauthorized users.
Read more >
3 Ways to Hide Navigation Bar in React Native Application
If you want to hide the header dynamically on click of a button then you can visit our post on Hiding React Navigation...
Read more >
How to reuse common layouts in Angular using Router
Problem with this approach is that layout is unnecessarily recreated on each route change. We can check that by putting console logs in...
Read more >
Angular Material Navigation Menu - Complete Responsive ...
We have to use angular routing as well, and we are going to do that ... on the end of the navbar and...
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