-
webbrowser연결 후 호출되는 시기.
window, document 등에 접근 가능.function App2() { useEffect(()=>{ console.log("UseEffectV1 main call window.document:" + window.document.nodeName); return ()=> { console.log("UseEffectV1 return call href:" + window.location.href); } }); let data1 = "aaa"; useEffect(()=>{ console.log("UseEffectV2 main call d: " + data1); return ()=> { console.log("UseEffectV2 return call d: " + data1); } }, [data1]); //useState에 의한 값이 아닌 경우 값 변화와 화면갱신,useEffect와는 무관. 화면에 갱신 되지 않음. setTimeout(() => {data1 = "bb"; console.log("chg d: " + data1);}, 1000); return ( <div > <h1> hello d: {data1}</h1> </div> ); } export default App2;
'NextJs' 카테고리의 다른 글
Nextjs Css 적용 기초 수준 Ex (0) 2023.01.11 Css(style) 파일 적용하기(Global, Module) (0) 2023.01.10 UseEffect Ex3 (0) 2023.01.10 UseEffect Ex2 (0) 2023.01.10 Cookie Ex1 (0) 2023.01.08 Nextjs Port 변경 (0) 2022.12.30 Warning: Prop `className` did not match. (0) 2022.12.25 Server side, Client side 실행 환경 (0) 2022.12.24