I am learning latest react features. As per docks memo works like shouldComponentUpdate or PureComponent in functional component but how do I use this memo concept in functional component.
Say I have below component using class
import React, { Component } from 'react';
class Test extends Component {
shouldComponentUpdate(nextProps, nextState) {
return this.props.text != nextProps.text;
}
render(){
const { text } = this.props;
return(
<div>
<h1>{text}</h1>
</div>
)
}
}
Functional component
function Test = props => {
const { text } = props;
return(
<div>
<h1>{text}</h1>
</div>
)
}
How can I write class component using memo in functional component