Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] is it normal that ComponentDidMount is triggerred twice when using next/link? #1966

Closed
lzgrzebski opened this issue May 14, 2017 · 3 comments
Assignees

Comments

@lzgrzebski
Copy link

So I have simply "single post page" that can be navigated through links (post?slug=x), and in getInitialProps Im dispatching action to get data for the singlePost, thing is that after clicking a link I have this scenario (in page single post page component):
shouldComponentUpdate -> componentDidUpdate -> componentDidUpdate (extra)
I would like to dispatch some additional actions after component will be loaded with the new post but its dispatching twice because of this.. or I just have a bug, but I spend some time on it already and it will be good to know if this is not a normal behaviour.

Menu with links: https://github.com/lzgrzebski/teachmesilence.com/blob/master/src/components/Menu/index.js
SinglePostContainer: https://github.com/lzgrzebski/teachmesilence.com/blob/master/src/containers/SinglePostContainer.js
post page: https://github.com/lzgrzebski/teachmesilence.com/blob/master/src/pages/post.js

@lfades
Copy link
Member

lfades commented Jul 25, 2017

I'm using a layout for all my pages in my app, the layout is always the same but componentDidMount and componentWillUnmount are always called when switching pages. I expected them to run only once :c

@timneutkens
Copy link
Member

@goluis the whole page is re-rendered on page changes. Even if it's the same page with different params.

@timneutkens
Copy link
Member

I think this was fixed when upgrading react-hot-loader. We're going to drop react-hot-loader all together soon.

@lock lock bot locked as resolved and limited conversation to collaborators May 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants