重组 withHandlers 回调不是触发器

Recompose withHandlers callback is not triggers

我正在尝试执行这样的验证:

 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 */
        }
    })
 )

出于某种原因,validate 处理程序从未执行过。

想法?

 const validateWithState = compose(
     withState('current', 'handleChange', {}),
     withState('isValid', 'validate', false),
     withHandlers({
        validate1: () => () => {
        }
     }),
     withHandlers({
        handleChange: ({current, handleChange, validate1}) => () => {
              /* logic here */
              handleChange(current, () => {
                   validate1() /* <--- here */
              })
        },
    })
 )

可能我们无法访问定义在同一 withHandlers 中的函数。它有点多余,但如果我们有以前的withHandlers,我们就可以访问。