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.

Particles re-renders on every state change even when it is separate from all the state changes.

See original GitHub issue

I wrapper all the components that have state changes into a wrapper but the Particles component still gets re-rendered on changes.

render() {
   const { isSignedIn, imageUrl, route, box, user } = this.state;
   return (
     <div className="App">
       <Particles className='particles' params={particlesOptions} />
       <ComponentsWrapper 
         isSignedIn={isSignedIn}
         imageUrl={imageUrl}
         route={route}
         box={box} 
         user={user}
         loadUser={this.loadUser}
         onInputChange={this.onInputChange}
         onImageSubmit={this.onImageSubmit}
         onRouteChange={this.onRouteChange}
       />
     </div>
   );
 }
}

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Here2Huynhcommented, Jun 9, 2018

I figured it out. Had to separate the components with state changes into a separate component. Thanks for your time!

0reactions
acnologiacommented, Aug 31, 2022

Oh that’s an interesting use case.

I haven’t really tried it yet because there are other features I’m trying to roll out atm, but I’ll definitely try by tomorrow and contact you if I run into any road blocks. Thanks again for your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Particles re-renders on every state change even when it is ...
I see. It is because the Wrapper component is the parent component and that component's state got changed, hence triggering the re-rendering.
Read more >
Does React re-render all components when any state ...
Essentially I have a context provider component wrapping many children components. Since I did this I'm having trouble with re-renders. More ...
Read more >
React re-renders guide: everything, all at once - Developer way
State changes are the “root” source of all re-renders. ... will re-render, even if they don't use the changed portion of the data...
Read more >
When does React re-render components? - Felix Gerschau
Changing the state means that React triggers an update when we call the setState function (in React hooks, you would use useState )....
Read more >
Why React Re-Renders - Josh W Comeau
I know some developers believe that every state change in React forces an application-wide render, but this isn't true. Re-renders only affect ...
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