trungdq88 / react-router-page-transition

Highly customizable page transition component for your React Router
https://trungdq88.github.io/react-router-page-transition
MIT License
542 stars 53 forks source link

Cannot read property 'classList' of null #34

Closed LukasBlu1 closed 6 years ago

LukasBlu1 commented 6 years ago

Hello thank you for the great module. I use it in a Meteor React setup and get the following error. What can I do to fix that?

`Warning: You tried to redirect to the same route you're currently on: "/de/products/overview"

TypeError: Cannot read property 'classList' of null at start (modules.js?hash=78ed49f27dcb9357e19b66e69aca843d232db816:79998) at meteor.js?hash=6d285d84547b3dad9717a7c89c664b61b45ea3d8:1117 at `

trungdq88 commented 6 years ago

Hi, can you provide an example of the bug on https://codesandbox.io/?

LukasBlu1 commented 6 years ago

Hi, thank you for the quick reply. Unfortunately, I can not publish the project. Can you give me general information about possible causes? That would be a great help to me. After that I will publish the solution.

trungdq88 commented 6 years ago

That error message is very general, I can't help you if I don't understand your problem. Sorry!

Richard-Thompson commented 6 years ago

So i have the same issue, i cant replicate it on sandbox. Here is the sand box: sandbox

And here is my project code. I just cant seem to figure it out. Any help would be appreciated. I suppose you would have to clone my project and see for yourself rather than me positing snippets of everything.

This is the error message: image

Richard-Thompson commented 6 years ago

I don't know if this is any help. Some one suggests its down to versions of react and react-dom.

joaovitoras commented 6 years ago

I have the same problem, when i choose this way to not render component https://reactjs.org/docs/conditional-rendering.html#preventing-component-from-rendering children null breaks code

trungdq88 commented 6 years ago

Since you can't reproduce the problem. My best guess is you are using function component.

If the children of <PageTransition> is a functional component, Example:

export default Home = () => <div>...</div>

Try convert it into a full component

export default class Home extends React.Component {
  render() {
    return <div>...</div>
  }
}

Let me know if that doesn't solve the issue.

trungdq88 commented 6 years ago

Close due to inactive.

tastyqbit commented 5 years ago

One of the routes must always match. You can add an empty div that returns by default if no other routes match:

<Route path="/" component={() => <div />} />