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.

Page transition rerendering component when _app state changes

See original GitHub issue

Hello,

I am using this component for transitioning routed component in nextjs.

Problem comes when you change something in state in _app.js file, which manages applications wrapper, render will fire, which is expected behavior. But along with it, children of <PageTransition> component will re-render. Now, this will unmount and mount everything inside.

There should be some kind of custom shouldComponentUpdate implementation that if children don’t change, you don’t re-render them. Since the point of transition is to animate only if children of <PageTransition> change.

I suppose this can be solved if you replace React.Component with React.PureComponent, i guess that shallow comparison of React will do the job.

Thanks, Mario

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
nwalters512commented, Jan 14, 2019

No worries, glad I could be of some help!

0reactions
borispoehlandcommented, Dec 21, 2020

+1, can’t find this in the readme

Read more comments on GitHub >

github_iconTop Results From Across the Web

State change not re-rendering component - Stack Overflow
You can update state from changed props using componentDidUpdate() or shouldComponentUpdate(). componentDidUpdate should be protected with ...
Read more >
How do I keep pages from re-rendering completely in Next.js?
if I have a page called a.js, b.js, and c.js. in each file it looks like this. a.js. import Progress from "../components/progress"; import...
Read more >
How and when to force a React component to re-render
The component did not change, so there was no re-rendering trigger. Here's why. React evaluates state changes by checking its shallow ...
Read more >
React.Component
An update can be caused by changes to props or state. These methods are called in the following order when a component is...
Read more >
21 Performance Optimization Techniques for React Apps
React builds and maintains an internal representation of the rendered UI (Virtual DOM). When a component's props or state changes, React ...
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