learning-react icon indicating copy to clipboard operation
learning-react copied to clipboard

안녕하세요 혹 변경되었는지 모르겠지만.. p501

Open lllilllilllilili opened this issue 3 years ago • 0 comments

제가 가지고 있는 5판 발행에서

p501 보면

SampleContainer.js 부분에

useEffect(() => {
    const fn = async () => {
      try {
        await getPost(1);
        await getUsers(1);
      } catch (e) {
        console.log(e);
      }
    };
    fn();
  }, [getPost, getUsers]);

로 작성하면 화면 렌더링 시 TypeError: users.map is not a function 로 나옵니다.

await getUsers(1);
await getPost(1);

로 작성해야 정상적으로 동작하더라구요.

Mount 되는 시점에서 똑같이 호출하지만 콘솔에서 찍어보면 store에 Users가 true로 찍히게 됩니다. (책에 코드 실행 시)

피드백 요청 드립니다.

감사합니다

lllilllilllilili avatar Aug 08 '21 02:08 lllilllilllilili