![](/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.