React-Redux是否在使用ownProps的连接组件上更新两次?

时间:2017-04-13 19:16:22

标签: javascript reactjs redux react-redux

const ConnectedComponent1 = connect(
  (state) => {return {options: state.option}}
)((props)=> {return (<Component2 options={props.options}/>)})

const Component2 = (props) => {
  const children = props.options.map(option=>{
    return (<ConnectedComponent3 option={option}/>)
  })
  return children
}

const ConnectedComponent3 = connect(
  (state, ownProps) => {return {optionB: state.options[ownProps.option.otherOptionId]}}
)((props)=> {return (<div>{props.option.id}{props.optionB.id}</div>)})
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>

让我们说如果我有这个

因为Connect()绑定到商店更新调用,当状态更新ConnectedComponent 2更新两次?一旦从绑定到商店更新,并从接收新道具一次?

如果它确实更新两次哪一个先发生?

0 个答案:

没有答案