함수를 실행하지 않고 호출만 했을 때 발생하는 오류
❗ Warning: Functions are not valid as a React child. This may happen if you return a Component instead of from render. Or maybe you meant to call this function rather than return it.
const Example=()=>{
...
}
return(
<span>{Example}</span>
);
위의 코드처럼 특정 함수를 만들고 render 부분에서 실행 안하고 함수만 호출시 위 같은 에러가 뜬다.
해결방법은 함수를 실행해주면 된다.
const Example=()=>{
...
}
return(
<span>{Example()}</span>
);
map 함수 사용 시 오류
❗ Expected an assignment or funcion call and instead saw and expression no-unused-expressions
중괄호, 소괄호 사용 주의 필요
map 함수에서 {} (중괄호) 사용 시 return 필요
map 함수에서 요소를 () (소괄호)에 담아서 사용
📌 참고자료