Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialhector alvarado
15,796 PointsThe render method on state --
So it re-render all the class each time we change the state?? so in bigger apps if we have many clases with render methods it will render all of them to change the states??
2 Answers
jlampstack
23,932 PointsHi, I am probably not the best person to answer this, but since I see no-one has answered I will do my best to try. Perhaps Guil Hernandez would be kind enough to comment.
I believe it will not render all the classes, but only the Class that the render() belongs to. If it were to execute on all classes, especially on larger projects it would use up unnecessary resources, slowing down our app.
If there are several props or states within the same render() method, they still wouldn't all get rendered. I'm not sure if this is what you meant?
This is because data usually changes when an action is performed such as clicking on a button. Clicking on a button triggers an event handler which it's binded to, and the event handler sets the state of the particular instance.
I suppose if there is more than one property in a single event handler it could potentially update multiple properties, but it wouldn't trigger every class, or every event handler, just the ones being targeted.
Thierry Mwamba
2,991 PointsHector, To add to what jaycode said, when it comes to an app with a lot more traffic that will require a lot of interaction, therefore, state changes, there is a more complexe state management tool called Redux. It stores all state management in a store, with the help of actions and reducers. You can learn more about it at https://redux.js.org/introduction/getting-started, and that should be the next course after React Basics