위에서 오류가 났다. isQualified는 filter메서드에 넣어지는 함수이다.
해결법
1. {} 를 ()로 바꿔준다
2. {} 를 쓰고 싶다면, { return ~~~}로 작성해준다.
화살표 함수의 주의사항
const Button = () => (
<button>Submit</button>
)
화살표 함수의 경우 ()로 감싸진 부분이 return으로 넘어간다
이 때에는 return을 작성해주지 않아도 된다.
const Button = () => {
<button>Submit</button>
}
console.log(Button); // undefined
}
반면에 {}로 감싸진 함수는 return이 없다면 반환하지 않는다.
const Button = () => {
return <button>Submit</button>
}
따라서 { }로 반환하고 싶다면 위처럼 작성해줘야 한다
'문제(이슈) 해결' 카테고리의 다른 글
React.js -Maximum update depth exceeded. 해결법 (0) | 2022.03.12 |
---|---|
weather icon 넣기 (0) | 2021.09.15 |
Uncaught TypeError: Cannot read property 'addEventListener' of null (0) | 2021.07.03 |