inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[리뉴얼] React로 NodeBird SNS 만들기

TypeError: Cannot destructure property 'mainPosts' of 오류 어디가 문제일까요...

1528

br

작성한 질문수 26

0

찾다가 몰라서 오류 질문이요

찾아도 안보입니다 ㅠㅠ

어딘가 빼먹은건가요??

연동이 안된건가요??

코드 이중에 하나인가요?

 

pages폴더 - index.js

import React from 'react';
import { useSelector } from 'react-redux';
import AppLayout from '../components/AppLayout';
import PostCard from '../components/PostCard';
import PostForm from '../components/PostForm';

const Home = () => {
    const {me} = useSelector((state) => state.user);
    const {mainPosts} = useSelector((state) => state.post);

    return (
        <AppLayout>
            {me && <PostForm />}
            {mainPosts.map((post) => 
                <PostCard key={post.id} post={post} />
            )}
        </AppLayout>
        );
};

export default Home;

store 폴더 - configureStore.js

import {createWrapper} from 'next-redux-wrapper';
import {createStore, applyMiddleware, compose} from 'redux';
import {composeWithDevTools} from 'redux-devtools-extension';
import createSagaMiddleware from 'redux-saga';
import reducer from '../reducers';
import rootSaga from '../sagas';

const loggerMiddleware = ({ dispatch, getState }) => (next) => (action) => {
    console.log(action);

    return next(action);
};

const configureStore = () => {
    const sagaMiddleware = createSagaMiddleware();
    const middlewares = [sagaMiddleware, loggerMiddleware];
    const enhancer = process.env.NODE_ENV === 'production'
    ? compose(applyMiddleware(...middlewares))
    : composeWithDevTools(applyMiddleware(...middlewares))

    const store = createStore(reducer, enhancer);
    store.sagaTask = sagaMiddleware.run(rootSaga)
    
    return store;
}

const wrapper = createWrapper(configureStore, {
    debug: process.env.NODE_ENV === 'development',
});

export default wrapper;

package.json

"dependencies": {
    "@ant-design/icons": "^4.7.0",
    "antd": "^4.23.1",
    "axios": "^0.27.2",
    "next": "^12.3.0",
    "next-redux-wrapper": "^6.0.2",
    "prop-types": "^15.8.1",
    "react-redux": "^8.0.2",
    "react-slick": "^0.29.0",
    "redux": "^4.2.0",
    "redux-devtools-extension": "^2.13.9",
    "redux-saga": "^1.2.1",
    "shortid": "^2.2.16",
    "styled-components": "^5.3.5",
    "update": "^0.7.4"
  },
  "devDependencies": {
    "babel-eslint": "^10.1.0",
    "eslint": "^8.23.1",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-jsx-a11y": "^6.6.1",
    "eslint-plugin-react": "^7.31.8",
    "eslint-plugin-react-hooks": "^4.6.0"
  }
}

강의는 redux-saga 연동하기 부분이에요

Next.js nodejs express react redux

답변 1

0

제로초(조현영)

reducers쪽에 rootReducer랑 postReducer 봐야할 것 같습니다

0

br

reducers 폴더 안에

index.js,

post.js,

user.js 이쪽인가요??

0

제로초(조현영)

네네 post 리듀서가 제대로 코딩이 안되어있거나 이상하게 연결되어있는듯 하네요

0

br

export defalut reducer 안되있었네여..ㅠ

다른곳도 대.소문자 오타 , import 빠뜨린게 껴있어서 .. 겨우 찾았습니다;;

감사합니다 해결했어요

넥스트 버젼 질문

0

90

2

로그인시 401 Unauthorized 오류가 뜹니다

0

104

1

무한 스크롤 중 스크롤 튐 현상

0

198

1

특정 페이지 접근을 막고 싶을 때

0

117

2

createGlobalStyle의 위치와 영향범위

0

103

2

인라인 스타일 리렌더링 관련

0

98

2

vsc 에서 npm init 설치시 오류

0

159

2

nextjs 15버전 사용 가능할까요?

0

166

1

화면 새로고침 문의

0

129

1

RTK에서 draft, state 차이가 있나요?

0

164

2

Next 14 사용해도 될까요?

0

455

1

next, node 버전 / 폴더 구조 질문 드립니다.

0

359

1

url 오류 질문있습니다

0

218

1

ssh xxxxx로 우분투에 들어가려니까 port 22: Connection timed out

0

391

1

sudo certbot --nginx 에러

0

1295

2

Minified React error 콘솔에러 (hydrate)

0

481

1

카카오 공유했을 때 이전에 작성했던 글이 나오는 버그

0

257

1

프론트서버 배포 후 EADDRINUSE에러 발생

0

341

1

npm run build 에러

0

526

1

front 서버 npm run build 중에 발생한 에러들

0

399

1

서버 실행하고 브라우저로 들어갔을때 404에러

0

351

2

css 서버사이드 랜더링이 적용되지 않아서 문의 드립니다.

0

291

1

팔로워 3명씩 불러오고 데이터 합쳐주는걸로 바꾸고 서버요청을 무한으로하고있습니다.

0

251

2

해시태그 검색에서 throttle에 관해 질문있습니다.

0

207

1