no message
This commit is contained in:
@@ -38,6 +38,27 @@ class Count extends Component{
|
||||
)
|
||||
}
|
||||
}
|
||||
// 写法1
|
||||
// const mapStateToProps=state=>({state})
|
||||
// const mapDispatchToProps=dispatch=>({
|
||||
// jia:data=>dispatch(createIncreementAction(data)),
|
||||
// jian:data=>dispatch(createDecreementAction(data)),
|
||||
// jiaAsync:(data,time)=>dispatch(createIncreementAsyncAction(data,time)),
|
||||
// })
|
||||
// const CountContainer=connect(mapStateToProps,mapDispatchToProps)(countUI)
|
||||
|
||||
// 写法2
|
||||
// const CountContainer=connect(
|
||||
// state=>({state}),
|
||||
// dispatch=>({
|
||||
// jia:data=>dispatch(createIncreementAction(data)),
|
||||
// jian:data=>dispatch(createDecreementAction(data)),
|
||||
// jiaAsync:(data,time)=>dispatch(createIncreementAsyncAction(data,time)),
|
||||
// })
|
||||
// )
|
||||
// (countUI)
|
||||
|
||||
// 写法3
|
||||
const CountContainer=connect(
|
||||
state=>({state}),
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect } from 'react'
|
||||
// 导入React Redux提供的Hooks
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
import reducer,{increment,decrement, fetchUsers, incrementByAmount} from './store/modules/users'
|
||||
import {increment,decrement, fetchUsers, incrementByAmount} from './store/modules/users'
|
||||
|
||||
export default function App(){
|
||||
// 结构出 list
|
||||
@@ -9,14 +9,13 @@ export default function App(){
|
||||
const dispatch = useDispatch()
|
||||
|
||||
// 使用useEffect触发异步请求执行
|
||||
// useEffect(()=>{
|
||||
// dispatch(fetchUsers())
|
||||
// },[dispatch])
|
||||
useEffect(()=>{
|
||||
dispatch(fetchUsers())
|
||||
},[dispatch])
|
||||
|
||||
const reload=()=>{
|
||||
dispatch(fetchUsers())
|
||||
console.log(fetchUsers())
|
||||
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user