-
카테고리
-
세부 분야
풀스택
-
해결 여부
미해결
Suspense 컴포넌트만 App.js에 있는데..
21.06.08 14:14 작성 조회수 84
0
안녕하세요, App.js 을 보면 Provider로 store를 연결시켜주는 코드가 없는데 리덕스 스토어를 리액트 내에서 사용 가능한지 여쭤보고싶습니다.
function App() {
return (
<Suspense fallback={<div>Loading...</div>}>
<NavBar />
<div style={{ paddingTop: '69px', minHeight: 'calc(100vh - 80px)' }}>
<Switch>
<Route exact path='/' component={Auth(LandingPage, null)} />
<Route exact path='/login' component={Auth(LoginPage, false)} />
<Route exact path='/register' component={Auth(RegisterPage, false)} />
<Route
exact
path='/product/upload'
component={Auth(UploadProductPage, true)}
/>
<Route
exact
path='/product/:productId'
component={Auth(DetailProductPage, null)}
/>
<Route exact path='/user/cart' component={Auth(CartPage, true)} />
</Switch>
</div>
<Footer />
</Suspense>
);
}
Supense 컴포넌트가 비동기작업을 해주며, 로딩시 로딩화면을 보여주는 컴포넌트역할로 알고있는데,
Provider와 같이 사용해도 되는걸까요?
답변을 작성해보세요.
1
John Ahn
지식공유자2021.06.14
안녕하세요 ~ 혹시 index.js 에 이미
ReactDOM.render(
<Provider
store={createStoreWithMiddleware(Reducer,
window.__REDUX_DEVTOOLS_EXTENSION__ &&
window.__REDUX_DEVTOOLS_EXTENSION__()
)}
>
<App />
</Provider>
, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
이렇게 provider를 사용하고 있지않나요 ~ ?!
답변 1