[React] Cannot find module 'react-dom/client' or its corresponding type declarations.ts(2307) | resolve 'react-dom/client' in '경로' Parsed request is a module
2023. 7. 25. 06:53
개발/Error note
npm run dev로 웹팩을 실행하는데 에러가 뭔가 왕창 났다. 가장 상단 에러는 resolve 'react-dom/client' in '경로' Parsed request is a module였다. client.jsx에서도 Cannot find module 'react-dom/client' or its corresponding type declarations.ts(2307)라는 오류가 뿜뿜하고있었다. import * as React from "react" import { createRoot } from "react-dom/client" import Games from "./Games" const container = document.getElementById("root") const root = cre..
[Typescript] TS2339: Property 'children' does not exist on type '{}'.
2023. 7. 12. 22:31
개발/Error note
const TodosContextProvider: React.FC = (props) => { ...코드생략 return ( {props.children} ); }; 강의를 따라하는데 props.children 은 따로 명시를 해주지 않아도 children이 자동으로 있다고 그냥 쭉쭉 진도나가는데 나는 자꾸 존재하지 않는다고 떴다. 시도1const TodosContextProvider: React.FC = (props) => { ...코드생략 return ( {props.children} ); };그래서 FC에 제네릭으로 빈 객체를 넣어줘봤다. 응 그래도 빨간줄 시도2type Props = { children: React.ReactNode; }; const TodosContextProvider: React..
[React] '파일명' cannot be used as a JSX component. Its return type 'Element | undefined' is not a valid JSX element. Type 'undefined' is not assignable to type 'Element | null'.
2023. 7. 11. 08:17
개발/Error note
실행 시 자꾸 위와 같은 오류가 떴다. '파일' cannot be used as a JSX component. Its return type 'Element | undefined' is not a valid JSX element. Type 'undefined' is not assignable to type 'Element | null'. 오류는 말그대로 JSX엘리먼트를 반환하고있지 않다는말이었다. const GameMatcher = () => { const params = useParams() if (!params) { return 일치하는 게임이 없습니다 } if (params.name === "number-baseball") { return } else if (params.name === "rock-s..
[Webpack] Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
2023. 6. 1. 20:51
개발/Error note
Set 'mode' option to 'development' or 'production' to enable defaults for each environment. npx webpack 으로 웹팩 실행 시 위와 같은 에러가 발생했다. 파일명 오타 ^^.. 하고 다시 npx webpack 을 하는데 TS18002: The 'files' list in config file 'tsconfig.json' is empty. 라는 에러가 발생했다. 응 또 오타.. 파일명을 제대로하니 Meterial Icon 익스텐션 로고도 제 할일을 찾았고 터미널에서도 잘 작동됐다. 진짜 오타왕 이나당..
[React] useEffect must not return anything besides a function, which is used for clean-up.....
2023. 5. 27. 21:28
개발/Error note
기능 구현중에 useEffect안에서 async - await 함수를 써야하는 경우가 생겼다. 아무생각없이 useEffect( async() => { const sampleFunction = await() => { ... } }, []) 처럼 쓰려고 했더니 아래처럼 useEffect must not return anything besides a function.. 어쩌구 오류가 났다. 해석해보니 useEffect 안에서 비동기 함수를 작성하는 법을 알려주고 있었다. 위 오류에서 안내해주는 설명서에 따라서 코드를 고쳤다. useEffect( () => { const fetchData = async () => { const sampleFunction = await() => { ... } } fetchData..