![](/img/trans.png)
[英]How to test the handlers in withHandlers, branch and withState of recompose with enzyme?
[英]Recompose : Equivalant of the combination withState/withHandlers with withStateHandlers
一个简单的问题:如果我想使用withStateHandlers而不是withState / withHandlers夫妇。 这等效于什么:
withState('value', 'updateValue', ''),
withHandlers({
onChange: ({updateValue}) => event => updateValue(event.target.value)
})
感谢您的回答 :)
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 }) }
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.