redux-logger 사용하기

참고문서

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')
);

좋은 웹페이지 즐겨찾기