一个简单的问题:如果我想使用withStateHandlers而不是组合的withState/withHandler。它的等价物是什么:
withState('value', 'updateValue', ''),
withHandlers({
onChange: ({updateValue}) => event => updateValue(event.target.value)
})感谢您的回答:)
发布于 2017-09-14 04:21:38
withStateHandlers没有命名stateUpdater (就像您的例子中的updateValue一样),所以您需要直接与状态交互。
withStateHandlers(
// you define the initial state
{ value: '' },
// this is handler - you return a new state - updated value in this case
{ onChange: () => event => ({ value: event.target.value }) }
)https://stackoverflow.com/questions/46199833
复制相似问题