[CHAM] redux state Reference
·
개인프로젝트/CHAM
리덕스에서 배열state를 가져와 map을 돌려 사용하려고 했다. 최신거부터 보여주기 위해 reverse를 하고 돌리는데 const productionState = useSelector((state) => state.productionData); 이 배열을 reverse 시키니까 참조한 메모리 값이 reverse되어버려 state의 배열도 바꿔버렸다. 이를 해결하기 위해 깊은복사를 이용했다. const productionData = [...productionState];