[英]Recompose : Equivalant of the combination withState/withHandlers with withStateHandlers
Simple question: if i want to use withStateHandlers instead of the couple withState/withHandlers. 一个简单的问题:如果我想使用withStateHandlers而不是withState / withHandlers夫妇。 What is the equivalant of this : 这等效于什么:
withState('value', 'updateValue', ''),
withHandlers({
onChange: ({updateValue}) => event => updateValue(event.target.value)
})
Thanks for your answer :) 感谢您的回答 :)
withStateHandlers
doesn't have named stateUpdater
(like updateValue
in your case), so you need to interact with the state directly. 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.