Mstar0816 / Portfolio

https://my-portfolio-ten-orpin-68.vercel.app
1 stars 0 forks source link

Inefficient Rendering #6

Open Mstar0816 opened 4 months ago

Mstar0816 commented 4 months ago

Rendering the entire component tree on every state change, even when only a small part has changed, can impact performance.

Mstar0816 commented 4 months ago

React Reconciliation: Understand React’s reconciliation process and component lifecycle to optimize rendering by updating only the necessary parts of the DOM.

Mstar0816 commented 4 months ago

Use shouldComponentUpdate: In class components, implement the shouldComponentUpdate lifecycle method to control when a component should re-render. class MyComponent extends React.Component { shouldComponentUpdate(nextProps, nextState) { // Compare nextProps and nextState // Return true or false based on the comparison }

render() { // Component rendering logic } }