Rego의 블로그
Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it. 본문
사소한 오류
Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.
RegularPark 2022. 9. 2. 14:37함수인 대상을 실행하지 않고 render 부분에 코딩하여 발생하는 문제
const setUsableLanguage = () => {
return usableLanguage.map((lang) => <li key={lang}>{lang}</li>);
};
const Skills = () => {
return (
<div className="skills">
<ul>
{usableLanguage.map((lang) => (
<li key={lang}>{lang}</li>
))}
</ul>
<ul>{setUsableLanguage}</ul>
</div>
);
};
const setUsableLanguage = () => {
return usableLanguage.map((lang) => <li key={lang}>{lang}</li>);
};
const Skills = () => {
return (
<div className="skills">
<ul>
{usableLanguage.map((lang) => (
<li key={lang}>{lang}</li>
))}
</ul>
<ul>{setUsableLanguage()}</ul>
</div>
);
};
setUsableLanguage 함수를 render 부분에서 실행시켜주면 정상작동한다.
'사소한 오류' 카테고리의 다른 글
'React' refers to a UMD global, but the current file is a module (0) | 2023.09.17 |
---|---|
Each child in a list should have a unique "key" prop. (0) | 2022.09.10 |
npm ERR! Cannot read properties of null (reading 'pickAlgorithm') (0) | 2022.08.27 |
opencv_worldxxxd.lib' 파일을 열 수 없습니다 (0) | 2022.03.24 |
error: src refspec master does not match any error: failed to push some refs to 오류 해결 (0) | 2022.01.26 |