From 26fd0da53e6e3a34f3c135e73e6b22b6af98534c Mon Sep 17 00:00:00 2001 From: "naveenrawat51@gmail.com" Date: Wed, 7 Dec 2022 09:51:19 +0530 Subject: [PATCH] updated #7. pure functional component info Updated Q. 7 how we can implement pure component in functional components. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 51666ed3..ef9a41dc 100644 --- a/README.md +++ b/README.md @@ -513,7 +513,7 @@ You can download the PDF and Epub version of this repository from the latest run 7. ### What are Pure Components? - *`React.PureComponent`* is exactly the same as *`React.Component`* except that it handles the `shouldComponentUpdate()` method for you. When props or state changes, *PureComponent* will do a shallow comparison on both props and state. *Component* on the other hand won't compare current props and state to next out of the box. Thus, the component will re-render by default whenever `shouldComponentUpdate` is called. + *`React.PureComponent`* is exactly the same as *`React.Component`* except that it handles the `shouldComponentUpdate()` method for you. When props or state changes, *PureComponent* will do a shallow comparison on both props and state. *Component* on the other hand won't compare current props and state to next out of the box. Thus, the component will re-render by default whenever `shouldComponentUpdate` is called. In functional componenets we use `React.memo()` API. `React.memo()` is a higher-order component. It takes a React component as its first argument and returns a special type of React component that allows the renderer to render the component while memoizing the output. Therefore, if the component’s props are shallowly equal, the `React.memo()` component will bail out the updates. **[⬆ Back to Top](#table-of-contents)**