I know that Stateless components are much more convenient to use (in specific scenarios). But since you cannot use shouldComponentUpdate, does this mean that the component will re-render for each attribute? My question is, is it better or not better (Performance-wise) to use a class component with intelligent mustComponentUpdate than to use a stateless component.
Are stateless components the best performance solution? consider this silly example:
const Hello =(props) =>(
<div>
<div> {props.hello}</div>
<div>{props.bye}</div>
</div>);
against
class Hello extends Component{
shouldComponentUpdate(nextProps){
return nextProps.hello !== this.props.hello
};
render() {
const {hello, bye} = this.props;
return (
<div>
<div> {hello}</div>
<div>{bye}</div>
</div>
);
}
}
, 2 , , ( ), Stateless ?
UPDATE
. ( shouldComponentUpdate), , . , :
- , PureComponent Component ( , mustComponentUpdate)
- , , rerender
- , ( )