์ด๋ฒคํธ(2)
-
[Reacte] Component Event ๋ง๋ค๊ธฐ
๐ ์ปดํฌ๋ํธ ์ด๋ฒคํธ ๋ง๋ค๊ธฐ return ( // Component๋ฅผ ๋ง๋ค ๋๋ ๋ฐ๋์ ํ๋์ ์ต์์ Tag๋ง (๋ฑ ํ๋) ์จ์ผ ํ๋ค. {this.props.title} {this.props.sub} ); ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ค๊ณ , ์ฌ์ฉ์ ์ ์ ์ด๋ฒคํธ๋ฅผ ์คํํ๊ณ ์ถ์ ๋, ์์ ๊ฐ์ด onChanePage๋ผ๋ ์ด๋ฒคํธ๋ฅผ ๋ง๋ค์ด์ ํน์ ํจ์๊ฐ ํธ์ถ๋๊ฒ ํ ์ ์๋ ๊ฒ์ด์์. App.js์์ ์์ ๊ฐ์ด onChanePage Event์ ํจ์๋ฅผ ๋ง๋ค๊ณ , {/*Stateํ ํ ๋ค ์ฝ๋*/} Subject.js์ ์์ ๊ฐ์ด a Tag๋ฅผ ๋๋ ์ ๋, ํจ์๊ฐ ์คํ๋๋๋ฐ, e.prevenDefulat()๋ก ๋จผ์ Reload๋ฅผ ๋ฐฉ์งํด์ฃผ๊ณ , App.js์ ์๋ onChagePage Event๋ฅผ ํจ์ ํ์์ผ๋ก ํธ์ถํด ์ฃผ๋ ๊ฒ์ด์์. ์ด..
2021.10.02 -
[Reacte] Event setState ํจ์
๐ Event setState ํจ์ ์ดํดํ๊ธฐ return ( {/* Stateํ ํ๊ธฐ ์ ์ฝ๋ */} {/**/} {/*Stateํ ํ ๋ค ์ฝ๋*/} {/**/} {this.state.subject.title} {this.state.subject.sub} ์์ ๊ฐ์ ์ฝ๋์์ ์ปดํฌ๋ํธ๊ฐ ์ด๋ฏธ ์์ฑ๋ ์ดํ์ [this.state.mode = 'welcome']์ฒ๋ผ State ๊ฐ์ ์ง์ ๋ณ๊ฒฝํ๋ฉด ์๋๊ณ , ํจ์ ํํ๋ก ๋ณ๊ฒฝํด์ผ ํ๋ ์ด์ ๋ฅผ ์์๋ณผ ๊ฒ์ด์์. constructor(props) { // State ๊ฐ์ ์ด๊ธฐํ ์ํค๊ธฐ ์ํจ์ด๊ณ , ๊ทธ ์ด๊ธฐ๊ฐ์ผ๋ก 'title="WEB" sub="word wide web!"'์ ์ค์ ํ๋ ค ํ๋ค. super(props); this.state = { mode : 'read', ..
2021.10.02