React 15.3 introduced PureComponent - a new way of implementing class-based components. It is now available to us alongside function-based components and components derived from React.Component.This new technique caused much confusion in React rounds. Is PureComponent a new improved version of React.Compoment? Does it automatically make everything better? Should you just slap PureComponent everywhere and enjoy your faster React app?What is PureComponentPureComponent is a base class for React class-based components. It implements shouldComponentUpdate lifecycle method like this:return ( !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) );It checks whether the state or props changed using shallow equality comparison.If the props and the state hasn't changed, the component is not re-rendered.shallowEqual performs a shallow equality check by iterating on the keys of the objects being compared and returning true when the values of a key in each object are not strictly equal.
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
reactjs,front-end-development,javascript
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
reactjs,front-end-development,javascript
No comments:
Post a Comment