Routing layout react-mobile

A route: container: {

login, //

register,

main

}

 

Configuration antdesign

Introduced redux

npm i --save react-redux redux-thunk

First create reducer.js store.js actions.js action-types.js

// Create function inside the reducer.js, use combineReducer merger reducer, become an object of external exposure

import  {combineReducer} from 'redux'

function xxx(state=0,action){

  return state

}

function yyy(state=0,action){

  return state

}

export default combineReducer({xxx,yyy})

// create objects inside the store

import {createStore,applyMiddleWare} from 'redux'

import reducer from './reducer.js'

import thunk from 'redux-thunk'

export default createStore(reducer,applyMiddleWare(thunk))

 

// js introduced at the inlet of the assembly App.js

import {Provider} from 'react-redux'

 
import store from './redux/store'
render() {
return (
<Provider store = {store}>
<HashRouter>
<Switch>
<Route path="/login" component={Login}></Route>
<Route path="/register" component={Register}></Route>
<Route path = "/" component = {Main}> </ Route> {/ * default components, will find a match is not preceded by a Main component * /}
</Switch>
</HashRouter>
</Provider>
)
}

 

Guess you like

Origin www.cnblogs.com/lucy-xyy/p/12525846.html