[英]Recompose withHandlers callback is not triggers
I'm trying to exec a validation like this: 我正在尝试执行这样的验证:
const validateWithState = compose(
withState('current', 'handleChange', {}),
withState('isValid', 'validate', false),
withHandlers({
handleChange: ({current, handleChange, validate}) => () => {
/* logic here */
handleChange(current, () => {
validate() /* <--- here */
})
},
validate: ({current}) => () => {
/* this line is never reached */
}
})
)
For some reason the validate
handler never executed. 由于某些原因,
validate
处理程序从未执行。
Ideas? 想法?
const validateWithState = compose(
withState('current', 'handleChange', {}),
withState('isValid', 'validate', false),
withHandlers({
validate1: () => () => {
}
}),
withHandlers({
handleChange: ({current, handleChange, validate1}) => () => {
/* logic here */
handleChange(current, () => {
validate1() /* <--- here */
})
},
})
)
Probably we can't access in a function which is defined in same withHandlers
. 可能我们无法访问与
withHandlers
相同的withHandlers
。 It's a bit redundant but we can access if we have previous withHandlers
. 这有点多余,但是如果我们以前有
withHandlers
则可以访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.