๋ชฉ์ฐจ
ReactJS Warning: Received the string `false` for the boolean attribute `disabled`. The browser will interpret it as a truthy value. Did you mean disabled={false}?
ReactJS input, select disabled ์ ์ด.
index.js:1 Warning: Received the string `false` for the boolean attribute `disabled`. The browser will interpret it as a truthy value. Did you mean disabled={false}?
at input
at td
at tr
at tbody
at table
at div
at CompanyInfo (http://localhost:3000/static/js/main.chunk.js:2621:3)
at CompanyInfoContainer
at Route (http://localhost:3000/static/js/vendors~main.chunk.js:63206:29)
at Switch (http://localhost:3000/static/js/vendors~main.chunk.js:63408:29)
at div
at div
at div
at CompanyManageLayout (http://localhost:3000/static/js/main.chunk.js:5053:3)
at Route (http://localhost:3000/static/js/vendors~main.chunk.js:63206:29)
at Switch (http://localhost:3000/static/js/vendors~main.chunk.js:63408:29)
at Router (http://localhost:3000/static/js/vendors~main.chunk.js:62841:30)
at ConnectedRouter (http://localhost:3000/static/js/vendors~main.chunk.js:2566:7)
at ConnectedRouterWithContext (http://localhost:3000/static/js/vendors~main.chunk.js:2689:25)
at ConnectFunction (http://localhost:3000/static/js/vendors~main.chunk.js:60203:75)
at App (http://localhost:3000/static/js/main.chunk.js:312:3)
at Provider (http://localhost:3000/static/js/vendors~main.chunk.js:59916:20)
๋ฆฌ์กํธ๋ก ํผ์ด ๋ค์ด๊ฐ ํ์ด์ง๋ฅผ ์์ฑํ๋ ์ค์ ์ด๋ฐ ์ค๋ฅ๊ฐ ๋ด๋ค.
ํ์๊ฐ ๋ง๋ค๋ ํ์ด์ง๋ ์ํ ๊ฐ์ ๋ฐ๋ผ์ 'viewDetail'์ผ ๋๋ ์์ธํ๋ฉด์ธ ๊ฒ์ฒ๋ผ ๋ณด์ฌ์ฃผ๋ค๊ฐ "์์ " ๋ฒํผ์ ๋๋ฅด๋ฉด 'viewEdit'๋ชจ๋๊ฐ ๋๋ ํ์ด์ง๋ค.
<input type="text" id="addr" disabled={modeDisabled} value={companyInfo.addr} ref={inpAddr}/>
์์ธํ๋ฉด์ผ๋ก ๋ณด์ฌ์ค ๋ disabled๊ฐ true๊ฐ ๋์ด์ผ ํด์
const [modeDisabled, setModeDisabled] = useState("false");
์ด๋ ๊ฒ ์์ฑํ๋๋ ๋ฐ์๋ ์ค๋ฅ๋ค.
์ ๋๋ก ์ฌ์ฉํ๋ ค๋ฉด "false"๊ฐ ์๋๋ผ false๋ฅผ ์จ์ค์ผ ํ๋ค.
const [modeDisabled, setModeDisabled] = useState(false);
์ด๋ ๊ฒ ์ ๋๋ก ์ฌ์ฉํ๋ฉด select๊ฐ ๋ฐ์๋ค์ด์ง ๋ชปํ๋ค.
์ด๋ด ๋
const [modeDisabled, setModeDisabled] = useState(false);
...
setModeDisabled(true);
useState๋ฅผ ์ด๋ ๊ฒ ํ์ฉํ๋ค.
์ค์ํ ์ ์ modeDisabled๊ฐ true์ผ ๋ disabled ํ๊ฒ ๋ค๋ ๋ป์ด๋ผ๋ ๊ฒ์ ๊ธฐ์ตํด์ผ ํ๋ค.
{ ...( modeDisabled && { disabled: true } ) }
๊ฐ ํผ ์์์์๋ ์ด๋ ๊ฒ ์ฌ์ฉํด ์ค๋ค.
modeDisabled===true ์ธ ์ํ๊ฐ์ ๊ฐ์ง ๋๋ง disabled:true๊ฐ ์ ์ฉ๋๋ค.
modeDsiabled===false๊ฐ์ผ ๋๋ disabled๋ ์ ์ฉ๋์ง ์๋๋ค.
ํ ํ์ด์ง์์ ์์ธ๋ณด๊ธฐ์ ์์ ์ ์ฒ๋ฆฌํ ์ ์๋ ๊ฒ์ด ์ฅ์ ์ด๋ค.
๋๊ธ