redux-logger 사용하기

Judo·2021년 1월 12일
0
post-custom-banner

참고문서

redux-logger 사용하기

  • redux-logger 설치
    npm install redux-logger

  • 적용

// index.js
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { applyMiddleware, createStore } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';

import { Provider } from 'react-redux';
import rootReducer from './modules/index';
import myLogger from './middlewares/myLogger';
import logger from 'redux-logger';


const store = createStore(rootReducer, applyMiddleware(logger))

                                              
ReactDOM.render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('root')
);

  • 콘솔 출력 화면

redux DevTools 사용하기

  • redux-devtools-extension 설치
    npm install redux-devtools-extension

  • 적용

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import { createStore, applyMiddleware } from 'redux';
import { Provider } from 'react-redux';
import rootReducer from './modules';
import logger from 'redux-logger';
import { composeWithDevTools } from 'redux-devtools-extension';

const store = createStore(
  rootReducer,
  composeWithDevTools(applyMiddleware(logger))
); // 여러개의 미들웨어를 적용 할 수 있습니다.

ReactDOM.render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('root')
);
profile
즐거운 코딩
post-custom-banner

0개의 댓글