Hi there,
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, isValid}) => () => {
/* this line is never reached */
}
})
)
For some reason the validate handler never executed.
Ideas?
@andresmijares All handlers can access only previously passed props. The can't access to each other. You can use two withHandlers hocs
Do you mean this possible?
withHandlers({
validate: ({current, isValid}) => () => {
/* this line is never reached */
}
}),
withHandlers({
handleChange: ({current, handleChange, validate}) => () => {
/* logic here */
handleChange(current, () => {
validate() /* <--- Now this has access to ^ */
})
},
}),
Thanks for ur response!
Yep :)
thank you for you fast response man!
It will be a good first PR https://github.com/acdlite/recompose/pull/333
as work on that PR seems like stopped
IMO it will be fine to have ability to have access to current handlers as at first comment.
I agree, I've been using this library since 3 days, ago, it took me 2 to understand how this works. I will try my best to collaborate.
PR to allow call internal handlers
https://github.com/acdlite/recompose/pull/401
Most helpful comment
Yep :)