#DON’T do this in REACT
When working with React, there are certain things that you should avoid doing in order to maintain a clean codebase and ensure that your application runs smoothly. Below are some things that you should avoid doing in React:
Using setState in componentDidMount
It is not recommended to use setState inside the componentDidMount lifecycle method. This can lead to performance issues and potential side effects. Instead, you should initialize your state in the constructor or use the new static getDerivedStateFromProps method introduced in React 16.3.
Direct DOM manipulation
One of the main benefits of using React is its virtual DOM, which allows for efficient updates and rendering. Directly manipulating the DOM can cause conflicts with React’s internal state management and lead to unexpected behavior. Instead, you should use React’s state and props to manage your application’s UI.
Not using keys in dynamic lists
When rendering dynamic lists in React, it is important to provide a unique key for each item. This helps React efficiently track and update the items in the list. If you don’t provide keys, React will have to re-render the entire list every time there is a change, which can lead to performance issues.
Using setState in a loop
Using setState in a loop can lead to unnecessary re-renders and performance issues. It is better to batch state updates using functional updates or by combining multiple state changes into a single setState call.
Not using shouldComponentUpdate
By default, React will re-render a component whenever its state or props change. This can lead to unnecessary re-renders and performance issues, especially for large and complex components. Implementing the shouldComponentUpdate method can help optimize your components by preventing unnecessary re-renders.
By following best practices and avoiding these common pitfalls, you can ensure that your React application runs smoothly and efficiently.
And the reason behind that even if you use class components then it will first convert your class components to functional component and then only it will execute that and that is extra step for react 😊
bro u know ben awad
Reply me lazmi.
Aap ko subscribe bhi kar diya hai.
Must must read.
⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️
Bus yah Bata Do Ki aap kaun sa code editor use karte ho ya console ki value code mein hi show kar raha hai yah kaun sa code editor hai lazmi reply karna.
Yes Use only functional based components
Class hum sharminda he tere katil jinda he 😢
There are many flaws in functional components major one like handling lifecycle methods
Sir which software use for edit Video
I need to know python
Can someone mentor me
But why
will there be any course on redux toolkit in future
Make some shorts on class components in interview they are asking about class components
Do I need to know DSA ? I'm not good at it no matter how much I practice..