async (1) 썸네일형 리스트형 React - 7 data-fetch [setTimeout, async/await] 컴포넌트가 실행될때 constructor -> render() -> componentDidMount() 이렇게 실행된다.그렇다면 6초후에 상태를 변경하고 싶다면? class App extends React.Component { state = { isLoading: true }; // render하면 진행되는 함수이다. 이함수는 setTimeout()함수를 통해 setState()를 6초 후에 시켰다. // 즉 data를 fetch 한것이다. componentDidMount() { setTimeout(() => { this.setState({ isLoading: false }); }, 6000) } render() { const { isLoading } = this.state; return ( {isLoa.. 이전 1 다음