Badal Sharma
Badal Sharma

Reputation: 69

How to make pure components in react js using functional approach i.e. non class based

How to make pure component using in functional react component ?

const MyComponent = () => { 
return (<h1>I am functional component.</h1>)
}
export default MyComponent;

How to make a pure component out of the above code ?

Upvotes: 1

Views: 1114

Answers (1)

Harshit Upadhyay
Harshit Upadhyay

Reputation: 159

you can use React.memo

import React from 'react';

const MyComponent = () => { 
return (<h1>I am functional component.</h1>)
}
export default React.memo(MyComponent);

Upvotes: 1

Related Questions