xx
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"ast":null,"code":"/*\n * @Author: chenxuan\n * @Date: 2022-07-31 23:04:08\n * @LastEditTime: 2022-08-02 00:12:32\n * @LastEditors: chenxuan\n */\nimport { ADDPERSON } from '../const';\nexport default function addPerson() {\n let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [{\n name: \"陈轩\",\n age: 18,\n id: 1\n }];\n let action = arguments.length > 1 ? arguments[1] : undefined;\n const {\n type,\n data\n } = action;\n\n if (type == ADDPERSON) {\n return [...state, data];\n } else {\n return state;\n }\n}","map":{"version":3,"names":["ADDPERSON","addPerson","state","name","age","id","action","type","data"],"sources":["/Users/chenxuan/Documents/code/react/demo/reduxOrigin2/src/redux/reducer/person.js"],"sourcesContent":["/*\n * @Author: chenxuan\n * @Date: 2022-07-31 23:04:08\n * @LastEditTime: 2022-08-02 00:12:32\n * @LastEditors: chenxuan\n */\nimport {ADDPERSON} from '../const'\nexport default function addPerson(state=[{name:\"陈轩\",age:18,id:1}],action){\n const {type,data}=action\n if(type==ADDPERSON){\n return [...state,data]\n }\n else{\n return state\n }\n}"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQA,SAAR,QAAwB,UAAxB;AACA,eAAe,SAASC,SAAT,GAA0D;EAAA,IAAvCC,KAAuC,uEAAjC,CAAC;IAACC,IAAI,EAAC,IAAN;IAAWC,GAAG,EAAC,EAAf;IAAkBC,EAAE,EAAC;EAArB,CAAD,CAAiC;EAAA,IAAPC,MAAO;EACrE,MAAM;IAACC,IAAD;IAAMC;EAAN,IAAYF,MAAlB;;EACA,IAAGC,IAAI,IAAEP,SAAT,EAAmB;IACf,OAAO,CAAC,GAAGE,KAAJ,EAAUM,IAAV,CAAP;EACH,CAFD,MAGI;IACA,OAAON,KAAP;EACH;AACJ"},"metadata":{},"sourceType":"module"}
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"ast":null,"code":"/*\n * @Author: chenxuan\n * @Date: 2022-06-25 16:54:00\n * @LastEditTime: 2022-08-01 23:17:13\n * @LastEditors: chenxuan\n */\nimport { createStore, applyMiddleware, combineReducers } from 'redux';\nimport countReducer from './reducer/count';\nimport personReducer from './reducer/person';\nimport thunk from 'redux-thunk';\nconst allReducer = combineReducers({});\nconst store = createStore(allReducer, applyMiddleware(thunk));\nexport default store;","map":{"version":3,"names":["createStore","applyMiddleware","combineReducers","countReducer","personReducer","thunk","allReducer","store"],"sources":["/Users/chenxuan/Documents/code/react/demo/reduxOrigin2/src/redux/store.js"],"sourcesContent":["/*\n * @Author: chenxuan\n * @Date: 2022-06-25 16:54:00\n * @LastEditTime: 2022-08-01 23:17:13\n * @LastEditors: chenxuan\n */\nimport {createStore,applyMiddleware,combineReducers} from 'redux'\nimport countReducer from './reducer/count'\nimport personReducer from './reducer/person'\nimport thunk from 'redux-thunk'\nconst allReducer=combineReducers({\n \n})\nconst store=createStore(allReducer,applyMiddleware(thunk))\nexport default store"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQA,WAAR,EAAoBC,eAApB,EAAoCC,eAApC,QAA0D,OAA1D;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,KAAP,MAAmB,aAAnB;AACA,MAAMC,UAAU,GAACJ,eAAe,CAAC,EAAD,CAAhC;AAGA,MAAMK,KAAK,GAACP,WAAW,CAACM,UAAD,EAAYL,eAAe,CAACI,KAAD,CAA3B,CAAvB;AACA,eAAeE,KAAf"},"metadata":{},"sourceType":"module"}
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"ast":null,"code":"/*\n * @Author: chenxuan\n * @Date: 2022-06-25 16:54:00\n * @LastEditTime: 2022-08-01 23:19:58\n * @LastEditors: chenxuan\n */\nimport { createStore, applyMiddleware, combineReducers } from 'redux';\nimport countReducer from './reducer/count';\nimport personReducer from './reducer/person';\nimport thunk from 'redux-thunk';\nconst allReducer = combineReducers({\n countReducer,\n personReducer\n});\nconst store = createStore(allReducer, applyMiddleware(thunk));\nexport default store;","map":{"version":3,"names":["createStore","applyMiddleware","combineReducers","countReducer","personReducer","thunk","allReducer","store"],"sources":["/Users/chenxuan/Documents/code/react/demo/reduxOrigin2/src/redux/store.js"],"sourcesContent":["/*\n * @Author: chenxuan\n * @Date: 2022-06-25 16:54:00\n * @LastEditTime: 2022-08-01 23:19:58\n * @LastEditors: chenxuan\n */\nimport {createStore,applyMiddleware,combineReducers} from 'redux'\nimport countReducer from './reducer/count'\nimport personReducer from './reducer/person'\nimport thunk from 'redux-thunk'\nconst allReducer=combineReducers({\n countReducer,personReducer\n})\nconst store=createStore(allReducer,applyMiddleware(thunk))\nexport default store"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQA,WAAR,EAAoBC,eAApB,EAAoCC,eAApC,QAA0D,OAA1D;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,KAAP,MAAmB,aAAnB;AACA,MAAMC,UAAU,GAACJ,eAAe,CAAC;EAC7BC,YAD6B;EAChBC;AADgB,CAAD,CAAhC;AAGA,MAAMG,KAAK,GAACP,WAAW,CAACM,UAAD,EAAYL,eAAe,CAACI,KAAD,CAA3B,CAAvB;AACA,eAAeE,KAAf"},"metadata":{},"sourceType":"module"}
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"ast":null,"code":"/*\n * @Author: chenxuan\n * @Date: 2022-06-25 16:54:00\n * @LastEditTime: 2022-08-01 23:17:13\n * @LastEditors: chenxuan\n */\nimport { createStore, applyMiddleware, combineReducers } from 'redux';\nimport countReducer from './reducer/count';\nimport personReducer from './reducer/person';\nimport thunk from 'redux-thunk';\nconst allReducer = combineReducers();\nconst store = createStore(allReducer, applyMiddleware(thunk));\nexport default store;","map":{"version":3,"names":["createStore","applyMiddleware","combineReducers","countReducer","personReducer","thunk","allReducer","store"],"sources":["/Users/chenxuan/Documents/code/react/demo/reduxOrigin2/src/redux/store.js"],"sourcesContent":["/*\n * @Author: chenxuan\n * @Date: 2022-06-25 16:54:00\n * @LastEditTime: 2022-08-01 23:17:13\n * @LastEditors: chenxuan\n */\nimport {createStore,applyMiddleware,combineReducers} from 'redux'\nimport countReducer from './reducer/count'\nimport personReducer from './reducer/person'\nimport thunk from 'redux-thunk'\nconst allReducer=combineReducers()\nconst store=createStore(allReducer,applyMiddleware(thunk))\nexport default store"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQA,WAAR,EAAoBC,eAApB,EAAoCC,eAApC,QAA0D,OAA1D;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,KAAP,MAAmB,aAAnB;AACA,MAAMC,UAAU,GAACJ,eAAe,EAAhC;AACA,MAAMK,KAAK,GAACP,WAAW,CAACM,UAAD,EAAYL,eAAe,CAACI,KAAD,CAA3B,CAAvB;AACA,eAAeE,KAAf"},"metadata":{},"sourceType":"module"}
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"ast":null,"code":"/*\n * @Author: chenxuan\n * @Date: 2022-06-25 16:54:00\n * @LastEditTime: 2022-08-01 23:16:08\n * @LastEditors: chenxuan\n */\nimport { createStore, applyMiddleware, combineReducers } from 'redux';\nimport countReducer from './reducer/count';\nimport addPerson from './reducer/person';\nimport thunk from 'redux-thunk';\nconst allReducer = combineReducers();\nconst store = createStore(allReducer, applyMiddleware(thunk));\nexport default store;","map":{"version":3,"names":["createStore","applyMiddleware","combineReducers","countReducer","addPerson","thunk","allReducer","store"],"sources":["/Users/chenxuan/Documents/code/react/demo/reduxOrigin2/src/redux/store.js"],"sourcesContent":["/*\n * @Author: chenxuan\n * @Date: 2022-06-25 16:54:00\n * @LastEditTime: 2022-08-01 23:16:08\n * @LastEditors: chenxuan\n */\nimport {createStore,applyMiddleware,combineReducers} from 'redux'\nimport countReducer from './reducer/count'\nimport addPerson from './reducer/person'\nimport thunk from 'redux-thunk'\nconst allReducer=combineReducers()\nconst store=createStore(allReducer,applyMiddleware(thunk))\nexport default store"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQA,WAAR,EAAoBC,eAApB,EAAoCC,eAApC,QAA0D,OAA1D;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,KAAP,MAAmB,aAAnB;AACA,MAAMC,UAAU,GAACJ,eAAe,EAAhC;AACA,MAAMK,KAAK,GAACP,WAAW,CAACM,UAAD,EAAYL,eAAe,CAACI,KAAD,CAA3B,CAAvB;AACA,eAAeE,KAAf"},"metadata":{},"sourceType":"module"}
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"ast":null,"code":"/*\n * @Author: chenxuan\n * @Date: 2022-07-31 23:01:33\n * @LastEditTime: 2022-08-01 23:56:10\n * @LastEditors: chenxuan\n */\nimport { ADDPERSON } from '../const';\n\nconst createPerson = data => ({\n type: ADDPERSON,\n data\n});\n\nexport default createPerson;","map":{"version":3,"names":["ADDPERSON","createPerson","data","type"],"sources":["/Users/chenxuan/Documents/code/react/demo/reduxOrigin2/src/redux/action/person.js"],"sourcesContent":["/*\n * @Author: chenxuan\n * @Date: 2022-07-31 23:01:33\n * @LastEditTime: 2022-08-01 23:56:10\n * @LastEditors: chenxuan\n */\nimport {ADDPERSON} from '../const'\nconst createPerson=data=>({type:ADDPERSON,data})\nexport default createPerson"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQA,SAAR,QAAwB,UAAxB;;AACA,MAAMC,YAAY,GAACC,IAAI,KAAG;EAACC,IAAI,EAACH,SAAN;EAAgBE;AAAhB,CAAH,CAAvB;;AACA,eAAeD,YAAf"},"metadata":{},"sourceType":"module"}
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"ast":null,"code":"/*\n * @Author: chenxuan\n * @Date: 2022-07-31 23:01:33\n * @LastEditTime: 2022-08-01 23:56:10\n * @LastEditors: chenxuan\n */\nimport { ADDPERSON } from '../const';\n\nconst createPerson = data => ({\n type: ADDPERSON,\n data\n});\n\nexport default createPerson = data => ({\n type: ADDPERSON,\n data\n});","map":{"version":3,"names":["ADDPERSON","createPerson","data","type"],"sources":["/Users/chenxuan/Documents/code/react/demo/reduxOrigin2/src/redux/action/person.js"],"sourcesContent":["/*\n * @Author: chenxuan\n * @Date: 2022-07-31 23:01:33\n * @LastEditTime: 2022-08-01 23:56:10\n * @LastEditors: chenxuan\n */\nimport {ADDPERSON} from '../const'\nconst createPerson=data=>({type:ADDPERSON,data})\nexport default createPerson=data=>({type:ADDPERSON,data})"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQA,SAAR,QAAwB,UAAxB;;AACA,MAAMC,YAAY,GAACC,IAAI,KAAG;EAACC,IAAI,EAACH,SAAN;EAAgBE;AAAhB,CAAH,CAAvB;;AACA,eAAeD,YAAY,GAACC,IAAI,KAAG;EAACC,IAAI,EAACH,SAAN;EAAgBE;AAAhB,CAAH,CAAhC"},"metadata":{},"sourceType":"module"}
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"ast":null,"code":"/*\n * @Author: chenxuan\n * @Date: 2022-07-31 23:01:33\n * @LastEditTime: 2022-07-31 23:03:29\n * @LastEditors: chenxuan\n */\nimport { ADDPERSON } from '../const';\nexport default createPerson = data => ({\n type: ADDPERSON,\n data\n});","map":{"version":3,"names":["ADDPERSON","createPerson","data","type"],"sources":["/Users/chenxuan/Documents/code/react/demo/reduxOrigin2/src/redux/action/person.js"],"sourcesContent":["/*\n * @Author: chenxuan\n * @Date: 2022-07-31 23:01:33\n * @LastEditTime: 2022-07-31 23:03:29\n * @LastEditors: chenxuan\n */\nimport {ADDPERSON} from '../const'\n\nexport default createPerson=data=>({type:ADDPERSON,data})"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQA,SAAR,QAAwB,UAAxB;AAEA,eAAeC,YAAY,GAACC,IAAI,KAAG;EAACC,IAAI,EAACH,SAAN;EAAgBE;AAAhB,CAAH,CAAhC"},"metadata":{},"sourceType":"module"}
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"ast":null,"code":"/*\n * @Author: chenxuan\n * @Date: 2022-06-25 16:54:00\n * @LastEditTime: 2022-08-01 23:16:08\n * @LastEditors: chenxuan\n */\nimport { createStore, applyMiddleware, combineReducers } from 'redux';\nimport countReducer from './reducer/count';\nimport addPerson from './reducer/person';\nimport thunk from 'redux-thunk';\nconst store = createStore(countReducer, applyMiddleware(thunk));\nexport default store;","map":{"version":3,"names":["createStore","applyMiddleware","combineReducers","countReducer","addPerson","thunk","store"],"sources":["/Users/chenxuan/Documents/code/react/demo/reduxOrigin2/src/redux/store.js"],"sourcesContent":["/*\n * @Author: chenxuan\n * @Date: 2022-06-25 16:54:00\n * @LastEditTime: 2022-08-01 23:16:08\n * @LastEditors: chenxuan\n */\nimport {createStore,applyMiddleware,combineReducers} from 'redux'\nimport countReducer from './reducer/count'\nimport addPerson from './reducer/person'\nimport thunk from 'redux-thunk'\nconst store=createStore(countReducer,applyMiddleware(thunk))\nexport default store"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQA,WAAR,EAAoBC,eAApB,EAAoCC,eAApC,QAA0D,OAA1D;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,KAAP,MAAmB,aAAnB;AACA,MAAMC,KAAK,GAACN,WAAW,CAACG,YAAD,EAAcF,eAAe,CAACI,KAAD,CAA7B,CAAvB;AACA,eAAeC,KAAf"},"metadata":{},"sourceType":"module"}
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"ast":null,"code":"/*\n * @Author: chenxuan\n * @Date: 2022-07-31 23:01:33\n * @LastEditTime: 2022-08-01 23:54:39\n * @LastEditors: chenxuan\n */\nimport { ADDPERSON } from '../const';\n\nconst createPerson = data => ({\n type: ADDPERSON,\n data\n});\n\nexport default createPerson;","map":{"version":3,"names":["ADDPERSON","createPerson","data","type"],"sources":["/Users/chenxuan/Documents/code/react/demo/reduxOrigin2/src/redux/action/person.js"],"sourcesContent":["/*\n * @Author: chenxuan\n * @Date: 2022-07-31 23:01:33\n * @LastEditTime: 2022-08-01 23:54:39\n * @LastEditors: chenxuan\n */\nimport {ADDPERSON} from '../const'\nconst createPerson=data=>({type:ADDPERSON,data})\nexport default createPerson"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQA,SAAR,QAAwB,UAAxB;;AACA,MAAMC,YAAY,GAACC,IAAI,KAAG;EAACC,IAAI,EAACH,SAAN;EAAgBE;AAAhB,CAAH,CAAvB;;AACA,eAAeD,YAAf"},"metadata":{},"sourceType":"module"}
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"ast":null,"code":"/*\n * @Author: chenxuan\n * @Date: 2022-07-31 23:01:33\n * @LastEditTime: 2022-08-01 23:56:10\n * @LastEditors: chenxuan\n */\nimport { ADDPERSON } from '../const'; // const createPerson=data=>({type:ADDPERSON,data})\n\nexport default createPerson = data => ({\n type: ADDPERSON,\n data\n});","map":{"version":3,"names":["ADDPERSON","createPerson","data","type"],"sources":["/Users/chenxuan/Documents/code/react/demo/reduxOrigin2/src/redux/action/person.js"],"sourcesContent":["/*\n * @Author: chenxuan\n * @Date: 2022-07-31 23:01:33\n * @LastEditTime: 2022-08-01 23:56:10\n * @LastEditors: chenxuan\n */\nimport {ADDPERSON} from '../const'\n// const createPerson=data=>({type:ADDPERSON,data})\nexport default createPerson=data=>({type:ADDPERSON,data})"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQA,SAAR,QAAwB,UAAxB,C,CACA;;AACA,eAAeC,YAAY,GAACC,IAAI,KAAG;EAACC,IAAI,EAACH,SAAN;EAAgBE;AAAhB,CAAH,CAAhC"},"metadata":{},"sourceType":"module"}
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* @Author: chenxuan
|
||||
* @Date: 2022-07-24 16:07:57
|
||||
* @LastEditTime: 2022-07-31 22:32:58
|
||||
* @LastEditTime: 2022-08-02 00:14:06
|
||||
* @LastEditors: chenxuan
|
||||
*/
|
||||
import React,{Component} from 'react'
|
||||
@@ -49,14 +49,10 @@ class Count extends Component{
|
||||
)
|
||||
}
|
||||
}
|
||||
const mapStateToProps=(state)=>{
|
||||
return {count1:state}
|
||||
}
|
||||
const mapDispatchToProps=(dispatch)=>{
|
||||
return {
|
||||
jia:data=>dispatch(createIncreementAction(data)),
|
||||
jian:data=>dispatch(createDecreementAction(data)),
|
||||
asyncJia:(data,time)=>dispatch(createIncreementAsyncAction(data,time))
|
||||
}
|
||||
}
|
||||
const mapStateToProps=state=>({count1:state.countReducer})
|
||||
const mapDispatchToProps=(dispatch)=>({
|
||||
jia:data=>dispatch(createIncreementAction(data)),
|
||||
jian:data=>dispatch(createDecreementAction(data)),
|
||||
asyncJia:(data,time)=>dispatch(createIncreementAsyncAction(data,time))
|
||||
})
|
||||
export default connect(mapStateToProps,mapDispatchToProps)(Count)
|
||||
@@ -1,18 +1,23 @@
|
||||
/*
|
||||
* @Author: chenxuan
|
||||
* @Date: 2022-07-31 21:43:44
|
||||
* @LastEditTime: 2022-07-31 23:26:07
|
||||
* @LastEditTime: 2022-08-02 00:18:10
|
||||
* @LastEditors: chenxuan
|
||||
*/
|
||||
import Rreact,{Component} from 'react'
|
||||
import {nanoid} from 'nanoid'
|
||||
import person from './style.module.css'
|
||||
export default class Person extends Component{
|
||||
import createPerson from '../../redux/action/person'
|
||||
import {connect} from 'react-redux'
|
||||
class Person extends Component{
|
||||
addPerson=()=>{
|
||||
const name=this.nodeName.value
|
||||
const age=this.nodeAge.value
|
||||
const personObj={id:nanoid(),name,age}
|
||||
this.props.createPerson(personObj)
|
||||
console.log(personObj)
|
||||
this.nodeName=''
|
||||
this.nodeAge=''
|
||||
}
|
||||
render(){
|
||||
return(
|
||||
@@ -22,13 +27,20 @@ export default class Person extends Component{
|
||||
<input type="text" ref={c=>this.nodeAge=c} placeholder='请输入年龄'/>
|
||||
<button onClick={this.addPerson}>添加</button>
|
||||
<ul>
|
||||
<li>名字-年龄</li>
|
||||
<li>名字-年龄</li>
|
||||
<li>名字-年龄</li>
|
||||
<li>名字-年龄</li>
|
||||
<li>{this.props.count}</li>
|
||||
{this.props.person.map((p)=>{
|
||||
return <div key={p.id}>
|
||||
<li>{p.name}</li>
|
||||
<li>{p.age}</li>
|
||||
</div>
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
export default connect(
|
||||
state=>({person:state.personReducer,count:state.countReducer}),
|
||||
{createPerson}
|
||||
)(Person)
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* @Author: chenxuan
|
||||
* @Date: 2022-07-31 23:01:33
|
||||
* @LastEditTime: 2022-07-31 23:03:29
|
||||
* @LastEditTime: 2022-08-01 23:56:10
|
||||
* @LastEditors: chenxuan
|
||||
*/
|
||||
import {ADDPERSON} from '../const'
|
||||
|
||||
export default createPerson=data=>({type:ADDPERSON,data})
|
||||
const createPerson=data=>({type:ADDPERSON,data})
|
||||
export default createPerson
|
||||
@@ -1,14 +1,13 @@
|
||||
/*
|
||||
* @Author: chenxuan
|
||||
* @Date: 2022-07-31 23:04:08
|
||||
* @LastEditTime: 2022-07-31 23:21:31
|
||||
* @LastEditTime: 2022-08-02 00:12:32
|
||||
* @LastEditors: chenxuan
|
||||
*/
|
||||
import {ADDPERSON} from '../const'
|
||||
export default function addPerson(state=[{name:"陈轩",age:18,id:1}],action){
|
||||
const {type,data}=action
|
||||
if(type==ADDPERSON){
|
||||
state.push(data)
|
||||
return [...state,data]
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
/*
|
||||
* @Author: chenxuan
|
||||
* @Date: 2022-06-25 16:54:00
|
||||
* @LastEditTime: 2022-07-31 23:06:58
|
||||
* @LastEditTime: 2022-08-01 23:19:58
|
||||
* @LastEditors: chenxuan
|
||||
*/
|
||||
import {createStore,applyMiddleware} from 'redux'
|
||||
import {createStore,applyMiddleware,combineReducers} from 'redux'
|
||||
import countReducer from './reducer/count'
|
||||
import addPerson from './reducer/person'
|
||||
import personReducer from './reducer/person'
|
||||
import thunk from 'redux-thunk'
|
||||
const store=createStore(countReducer,applyMiddleware(thunk))
|
||||
const allReducer=combineReducers({
|
||||
countReducer,personReducer
|
||||
})
|
||||
const store=createStore(allReducer,applyMiddleware(thunk))
|
||||
export default store
|
||||
Reference in New Issue
Block a user