关于迷你react-redux这一块

来源:12-8 迷你react-redux实现

雪挽

2018-01-10

迷你react-redux代码里是这样写的

export const connect = (mapStateToProps = state => state, mapDispatchToProps = {}) => (WrapComponent) => {}

可是定义和老师示例中时候connect里mapStateToProps 是一个没有传参数的函数。

例子里@connect(

state =>{num: state}


state =>{num: state}这个函数并没有接受参数

可是在react-redux里的实现代码里

const stateProps = mapStateToProps(store.getState())中 store.getState()是怎么传进去的 这块没太理解


写回答

1回答

Jaffar

2018-01-13

state =>{num:state}

把箭头函数去掉是一个匿名函数,是这样写的

funciont(state){
    return {num : state}
}

state就是参数啊

0
0

Redux+React Router+Node.js全栈开发

全网唯一的React 16+Redux+React Router4实战课程,学到手是你的真本领!

1822 学习 · 750 问题

查看课程