filmov
tv
React Hooks Tutorial - 8 - Memo and PureComponent
Показать описание
In react, components can be defined as functions or ES6 classes. All class components are sub classes of either Component or PureComponent. To understand when PureComponent base class is used for declaring your class component, it is important to understand when a react component defined as a sub class of Component re-renders.
When a class component is a sub class of Component, it is re-rendered whenever:
1) state changes
2) context changes
3) parent re-renders
4) props change
You can see from the above that a component is re-rendered whenever its parent re-renders though its context, state or props haven't changed. To prevent a component from re-rendering because of its parent's re-render, you can declare it as a sub class of PureComponent. PureComponent implements shouldComponentUpdate out of the box. It does a shallow comparison of props and state. If the state and props haven't changed, react doesn't re-render the component even if the parent re-renders. Since this is a shallow comparison, pureComponent should be avoided if your component is deeply nested because react can produce false-negatives for deeper differences. It should only be used if the component is pure.
React Native | React Native tutorial | React Native app | React Native tutorial for beginners | React Native crash course | React Native project | React Native app tutorial | React | mobile app development | tutorial | React Native for beginners | app development | React-Native | programming | React Native course | learn React Native | React Native 2020 | learn React | ReactNative | React Native mobile app | React Native full course | React Native hooks | React Native ui design | React Native ui | React tutorial | React vs React Native | beginners | javascript | React Native live coding | React-Native tutorial | React Native project tutorial | React Native tutorials for beginners | mobile development | what is React Native | React ntive app | React Native navigation | React Native list | React navigation | React Native projects for beginners | set up React Native | design to React Native | React Native code | adding font to React Native | React Native project setup | build an app | learn app development | let's code React Native | install React Native | React Native setup | React Native vs code | React Native introduction | React Native windows | javascript mobile app | React Native basics | React Native beginner tutorial | why learn React Native | what is React Native used for | why React Native | why React Native is not garbage | introduction to React Native | create React Native app | React Native forms | React Native app build | React Native beginner | intro to React Native | React Native scrollview | React Native scroll view | React Native flat list | flatlist React Native | flat list component | React Native lists | React Native usestate | React Native text input | React text input | React Native animated splash screen | React Native animatable | React Native login signup and navigation example | React Native login screen | React Native linear gradient tutorial | React Native splash screen | React Native splash screen animation | login & signup ui in React Native | login and signup screen in React Native | React Native linear gradient | beginner app | drawer navigator | drawer navigation | stack navigation | app build | React app | React navigator | scroll view | React list | list data
join our telegram community
#jasacadamy #reactj #memo #PureComponet
When a class component is a sub class of Component, it is re-rendered whenever:
1) state changes
2) context changes
3) parent re-renders
4) props change
You can see from the above that a component is re-rendered whenever its parent re-renders though its context, state or props haven't changed. To prevent a component from re-rendering because of its parent's re-render, you can declare it as a sub class of PureComponent. PureComponent implements shouldComponentUpdate out of the box. It does a shallow comparison of props and state. If the state and props haven't changed, react doesn't re-render the component even if the parent re-renders. Since this is a shallow comparison, pureComponent should be avoided if your component is deeply nested because react can produce false-negatives for deeper differences. It should only be used if the component is pure.
React Native | React Native tutorial | React Native app | React Native tutorial for beginners | React Native crash course | React Native project | React Native app tutorial | React | mobile app development | tutorial | React Native for beginners | app development | React-Native | programming | React Native course | learn React Native | React Native 2020 | learn React | ReactNative | React Native mobile app | React Native full course | React Native hooks | React Native ui design | React Native ui | React tutorial | React vs React Native | beginners | javascript | React Native live coding | React-Native tutorial | React Native project tutorial | React Native tutorials for beginners | mobile development | what is React Native | React ntive app | React Native navigation | React Native list | React navigation | React Native projects for beginners | set up React Native | design to React Native | React Native code | adding font to React Native | React Native project setup | build an app | learn app development | let's code React Native | install React Native | React Native setup | React Native vs code | React Native introduction | React Native windows | javascript mobile app | React Native basics | React Native beginner tutorial | why learn React Native | what is React Native used for | why React Native | why React Native is not garbage | introduction to React Native | create React Native app | React Native forms | React Native app build | React Native beginner | intro to React Native | React Native scrollview | React Native scroll view | React Native flat list | flatlist React Native | flat list component | React Native lists | React Native usestate | React Native text input | React text input | React Native animated splash screen | React Native animatable | React Native login signup and navigation example | React Native login screen | React Native linear gradient tutorial | React Native splash screen | React Native splash screen animation | login & signup ui in React Native | login and signup screen in React Native | React Native linear gradient | beginner app | drawer navigator | drawer navigation | stack navigation | app build | React app | React navigator | scroll view | React list | list data
join our telegram community
#jasacadamy #reactj #memo #PureComponet
Комментарии