안녕 버그친구들
리액트 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.
정ㅇr
2021. 11. 15. 17:31
728x90
// render() 부분 코드 일부
const inventoryListBySO = () => {
let result = [];
let numberForKey = 0;
pricePolicyStore.selectedInventoryList.length > 0 &&
// ... 생략
};
// return() 부분 코드 일부
// 처음에 inventoryListBySO 라고만 선언함
<GridItem xs={12} sm={10}>
<ol>
{inventoryListBySO()}
</ol>
</GridItem>
render() 부분에 함수를 선언하고, return 부분에서 이 함수를 실행을 안해줘서 생긴 버그다.
함수로 선언했으니까 당연히 실행을 해줘야 코드가 돌아가는데, 함수명만 선언해줘서 코드가 작동을 안했다.
참고한 사이트
반응형