본문 바로가기
반응형

Frontend5

[ React ] Expected an assignment or function call and instead saw an expression 오류 해결 방법 💥 React 실행 후 발생한 에러 메시지ERROR[eslint] src/App.js Line 49:13: Expected an assignment or function call and instead saw an expression no-unused-expressionsSearch for the keywords to learn more about each error. ✅ 해결 방법'{'를 생략해 줍니다.setTodoData(prev => {[...prev, newTodo]})setTodoData(prev => [...prev, newTodo]) 2024. 7. 15.
[ React ] Warning: Each child in a list should have a unique "key" prop. 오류 해결 방법 💥 React 실행 후 발생한 에러 메시지Warning: Each child in a list should have a unique "key" prop.Check the render method of `App`. See https://reactjs.org/link/warning-keys for more information.❓에러 발생 이유React의 리스트 요소에 uinque 한 key 값이 없어서 발생하는 오류입니다.React는 가상 DOM을 사용하여 Diffing 작업을 수행합니다.하지만 unique 한 key 값이 없으면 각각의 리스트 요소를 구분할 수 없기 때문에 발생하는 오류 에러 메시지입니다. 추가로 아래는 React 공식문서로 key에 대한 설명글입니다.https://react.dev/l.. 2024. 7. 12.
[ React ] SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag. 오류 해결 방법 💥 React 실행 후 발생한 에러 메시지Compiled with problems:ERROR in ./src/App.jsModule build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: /Users/user/Documents/study/react/sec02/src/App.js: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment ...? (37:12) ❓에러 발생 이유JSX 문법 오류 입니다. JSX는 기본적으로 부모 요소(Element)를 사용해야합니다.하지만 부모 요소(Element)가 존재하지 않아서 나타난 문법 오.. 2024. 7. 12.
[JS] Uncaught SyntaxError: Cannot use import statement outside a module 에러 해결 방법 💥 console 에러 메시지Uncaught SyntaxError: Cannot use import statement outside a module❓에러 발생 이유브라우저가 해당 script를 ES6 모듈로 인식하지 못해서 발생하는 문제입니다. ✅ 해결 방법-->수정 코드 math.jslet pi = 3.14;export { pi }; index.jsimport { pi } from "./math.js";console.log(pi);참고로  태그에type="module"를 추가하면 strict-mode가 활성화됩니다. 2024. 7. 10.
반응형