TIL/REACT
PureComponent & props 사용 방법
by koreashowme
2019. 10. 11.
import React, { PureComponent, memo } from 'react';
class Try extends PureComponent {
shouldComponentUpdate(nextProps, nextState, nextContext){
}
render(){
const { tryInfo } = this.props;
return (
<li>
<div>{tryInfo.try}</div>
<div>{tryInfo.result}</div>
</li>
)
}
}
// hooks 에서는 PureComponent도 없고, shouldComponentUpdate도 없다.
// memo를 써준다.
const Try = memo(({ tryInfo }) => {
return(
<li>
<div>{tryInfo.try}</div>
<div>{tryInfo.result}</div>
</li>
)
})
export default Try;
comment