๋คํฌ๋ชจ๋๋ฅผ ๊ตฌํํ๋ ์ค... ๋ง์ดํ ์๋ฌ...
๋๋ ์ฌ์ฉ๋ ์ํ ํ์
์ด ์๋ฌ๊ฐ ๋ฌ๋ค๊ณ ..
Uncaught TypeError: Cannot read properties of null (reading 'useContext')
react.development.js:209 Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
- React์ ๋ ๋๋ฌ(์: React DOM)์ ๋ฒ์ ์ด ์ผ์นํ์ง ์์ ์ ์์ต๋๋ค.
- Hooks์ ๊ท์น์ ์๋ฐํ๊ณ ์์ ์ ์์ต๋๋ค.
- ๊ฐ์ ์ฑ์ ๋ ์ด์์ React ์ฌ๋ณธ์ด ์์ ์ ์์ต๋๋ค.
https://react.dev/warnings/invalid-hook-call-warning
์ฌ๊ธฐ์ ์์ธ์ ์ฐพ์๋ณด์ธ์~! ๋ผ๊ณ ํ๋๋ฐ
์ผ๋จ์ ๊ตฌ๊ธ๋ง์ ์ด์ฌํ ํด๋ดค๋ค..
์คํ์ค๋ฒํ๋ก์ฐ ๊ฒ์๊ธ์ ์ง์ง ์ ๋ถ ๋ค ๋ณธ ๊ฒ ๊ฐ๋ค.. ๊ฑฐ๊ธฐ์ ํด๊ฒฐํ๋ผ๊ณ ํ๋ ๊ฒ๋ค์ ์ฌ๋ฌ ๊ฐ ์ ์ด๋ณด์๋ฉด,
React, React-dom ๋ฒ์
16 ์ดํ๋ฉด ํ ์ ์ฌ์ฉํ ์ ์๋ค๊ธธ๋ ํ์ธํ๋๋ ๋ฒ์ ์ ๊ด์ฐฎ์๋ฐ.
์ฌ๋ฌ ๊ฐ์ ๋ฆฌ์กํธ ์ค์น
์ฌ์ค ๋ฆฌ์กํธ ์ค์นํ ๋ ์ ํ๋ธ๋ฅผ ์ข ๋ดค๋๋.. (ใ
ใ
)
์ค๊ฐ์ ๋ฉ์ถฐ์ ธ ์์ด์ ๊ฐ์ ๋ก (^c) ์ฌ์ค์น๋ฅผ ์์ผ์คฌ๋ค
๊ทธ๋์ ๋ฌธ์ ๋ ์ฌ๊ธฐ ์๋ ๊ฑด๊ฐ ์ถ์ด์ ๋ ์ฐพ์๋ดค๋๋ฐ
npm ls react
์ด๋ ๊ฒ ๋์์์๊ณ ,
๊ตฌ๊ธ์์ ์ฐพ์๋ ํด๊ฒฐ์ฑ
์ผ๋ก๋
package.json์ devDependencies์ ์๋ react์ react-dom์ peerDependencies๋ก ์ฎ๊ธฐ๋ผ ํ๋ค.
"devDependencies": {
"@types/react": "^17.0.14",
"@types/react-dom": "^17.0.9",
"prettier": "^2.3.2",
"typescript": "^4.3.5",
"react": "^18.2.",
"react-dom": "^18.2.0"
},
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
๊ทธ๋ฐ๋ฐ๋ ํด๊ฒฐ์ด ๋์ง ์์๊ณ ....
์ค๋ณต์ด๊ธด ํ๊ฑด๊ฐ ์ถ์ด node-moduleํด๋์ package.json์ ์ง์ฐ๊ณ ์ฌ ์ค์นํด๋ ์๋ผ์
์์ ๋ค ๊ฐ์ ์๊ณ ๋ค์ ์์ํ๋๋ฐ๋ ๋๊ฐ์ ์ค๋ฅ๊ฐ ๋์๋ค.
์๋ชป๋ Hooks ๊ท์น
https://reactjs.org/docs/hooks-rules.html
ํ์ง๋ง, ๋๋ ๋ชจ๋ Hooks๋ฅผ ์ต์์์์ ์ฌ์ฉํ๊ณ ..
์ฝ๋์๋ ๋ฌธ์ ๊ฐ ์์๋ค.
์ด์ ์ฒ์์ผ๋ก ๋์๊ฐ๋ณด์.. ์๊ฐ์ ํด์
์ฝ์์ฐฝ์ ๋์๋ ์ฌ๊ธฐ์ ํด๊ฒฐํ์ธ์~ ํ๋ ๋งํฌ์ ๋ค์ด๊ฐ๋ดค๋ค
๋ฅผ ๋ณด๊ณ ... react-native.. ๋ฅผ ํ์ธํด๋ณด์๋๋ฐ..
empty..?????
๊ทธ๋์ ์ผ๋ฅธ ์ค์นํด์คฌ๋ค ใ
ใ
๊ทธ๋ฌ๋๋ ์ฌํ์๋ ๋ค๋ฅธ ์ค๋ฅ๊ฐ ํ๋ ๋์๋ค
Module not found: Error: Can't resolve 'react-dom/client'
๊ทธ๋์ react-dom์ ๋ค์ ์ค์นํด์ฃผ์๋ค.
๊ทธ๋ฌ๋๋ ๋ชจ๋ ์ค๋ฅ๊ฐ ํด๊ฒฐ๋์๋ค ใ
ใ
์๋ฐ์คํฌ๋ฆฝํธ๋ฅผ ์ธ ๋๋ ์ด๋ฐ์ ์ด ์์๋๋ฐ,
์ด์งธ์ ์ด๋ฐ ๋ฐ๋ณด๊ฐ์ ์ค๋ฅ๋ฅผ ๋ด๊ณ ๊ณ ์น์ง๋ ๋ชปํ๊ณ ์ดํ(์ด๋ผ ํ๊ณ ๋ช์๊ฐ์ด๋ผ๊ณ ์ฝ)์ ํค๋งจ ๊ฑด์ง ใ
ใ
๊ฒฐ๋ก ..! ์ค๋ฅ ๋ฉ์์ง์ ๋ต์ด ์๋ฐ
'์ฝ๋ฉ ๋ฉ๋ชจ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[error] Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'. (0) | 2023.05.20 |
---|---|
์๋๊ฒฝ๋ก์ ์ ๋๊ฒฝ๋ก (0) | 2023.05.20 |
git master main ํฉ์น๊ธฐ (0) | 2023.05.19 |
React์์ importํ ๋ {}์ค๊ดํธ ์ ๋ฌด์ ์๋ฏธ! (0) | 2023.05.19 |
git pull ์ค๋ฅ ํด๊ฒฐ ๋ชฉ๋ก (0) | 2023.05.18 |