剧场模式
首页React & Redux 实现注册登录认证系统

React & Redux 实现注册登录认证系统 #2 搭建前端代码

下载源码hfpp2012发布于1475 次点击播放时长:06:05
1

$ mkdir reduxlogin
$ cd reduxlogin
$ yarn start
$ yarn add redux react-redux
$ yarn add redux-logger redux-devtools-extension --dev
$ yarn add redux-thunk

client/src/index.js

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

import logger from 'redux-logger';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';

import { createStore, applyMiddleware } from 'redux';

import rootReducer from './reducers';

import { Provider } from 'react-redux';

const store = createStore(
  rootReducer,
  composeWithDevTools(
    applyMiddleware(thunk, logger)
  )
);

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

client/src/reducers/auth.js

const auth = (state = {}, action = {}) => {
  switch(action.type) {
    default: return state;
  }
}

export default auth;

client/src/reducers/index.js

import { combineReducers } from 'redux'

import auth from './auth';

export default combineReducers({
  auth
});
2 条回复
播放列表目录
你也想拥有自己的网站,并成为一名自由的讲师吗?
扫码打赏 16.8 元起加我微信拉入微信群

加我微信:15014006126

加 QQ 群:697272886

打赏的朋友或 Pro 学员获得特权

  • 加我微信拉你进微信群,享有更多互动和人脉资源;

  • 和程序员老兵我成为微信好友;

  • 不定期技术分享和视频问题解答

相似的视频

© Rails365 | 隐私条款 | 服务条款 | 加盟本站 | 粤ICP备15004902号 | 在线学员:11

Top