본문 바로가기
반응형

error3

[React 오류] validateDOMNesting(...): <tr> cannot appear as a child of <div> -React 에서 Table 사용 시 오류 validateDOMNesting(...): cannot appear as a child of 오류는 calendar를 만들때 생겼는데 의 자식으로 이 올 수 없다 는 경고였다. 📌 상황 const DayViewTR = () => { return ( 일 월 화 수 목 금 토 ); }; const DayViewTRDiv = styled.tr` `; const DayViewTD = styled.td` `; 보면 table 선언 없이 과 태그를 사용했다. 찾아보니 React의 jsx 문법에서는 table, tbody, thead 를 반드시 써서 table을 사용해야 한다고 한다. td, tr : tbody로 감쌈 th : thead 로 감쌈 실제 React에서 올바르게 table을 사용하려면 위처럼 thead.. 2021. 5. 25.
[React 오류] React Hook useEffect has a missing dependency: ' '. Either include it or remove the dependency array react-hooks/exhaustive-deps ⚠️ React Hook useEffect has a missing dependency: ' '. Either include it or remove the dependency array react-hooks/exhaustive-deps 상황 const MainDish = (props) => { const [data, setData] = useState([]); useEffect(() => { loadData(setData, props._dishType); }, []); return data.map((dish,i)=>{ } ); } React Hook인 useEffect를 이용해 data를 뿌려주는 상황 useEffect 내부에 loadData라는 함수를 사용하고 있음 const loadData = asy.. 2021. 4. 29.
[react 에러 ]Error: input is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`. react 로 Component를 새로 만들면서 styled Component를 사용해야 하는데 난 에러! Error: input is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`. 해결 과정 styled component 를 사용해 input 을 만든 후에 자식 tag를 넣어줘서 발생한 에러. input은 자식 tag(children)을 가질 수 없기 때문에 감싸주는 것은 div로 바꿔줘야 함 수정 전 //styled Component 생성 const IconWrapper = styled.input` display: flex; flex-direction: column; `; //return 수정.. 2021. 4. 28.
반응형