繁体   English   中英

重组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 这有点多余,但是如果我们以前有withHandlers则可以访问。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM