21.01.05 shouldComponentUpdate, teachable machine(google)
React
shouldComponentUpdate 는 render()를 호출할지 말지 도와준다.
기본적으로 부모의 component에 변경이 생기면 관계없는 자식의 component도 다시 render()가 되는데,
shouldComponentUpdate는 불필요시에 다시 한 번 호출되는 것을 막아준다.
shouldComponentUpdate 는 기본적으로 true 값을 반환하며
false 값을 반환할시, 불필요한 render를 방지해준다.
shouldComponentUpdate(newProps, newState){
console.log(
,newProps.data//바뀐 정보
,this.props.data//이전의 정보
);
if(this.props.data===newProps.data){
//정보의 변화가 없으면 아래의 render가 호출되지 않게 해줌.
return false;
}
return true; //기본적으로 true 반환
}
Machine Learning
간단한 machine learning을 도와주는 google에서 제공해주는 사이트 teachablemachine.withgoogle.com/
Teachable Machine
Train a computer to recognize your own images, sounds, & poses. A fast, easy way to create machine learning models for your sites, apps, and more – no expertise or coding required.
teachablemachine.withgoogle.com