-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a HOC to provide a onChange without name required #23
Comments
Great suggestion! Indeed, we need an adapter that includes the Could be called export const fromValue = memoize(path => {
return branch(
hasProp('onChange'),
withHandlers({
onChange: ({ onChange, name }) => value =>
onChange(path == null ? value : get(value, path), name),
}),
)
}) |
Sure we can do that but I still don't understand why the In other words, what would be the cost of turning this code: into withHandlers({
property: ({ value, onChangeProperty }) => (
name,
key = name,
) => ({
value: value[name],
key,
name,
onChange: (value, payload) => onChangeProperty(value, name, payload),
}),
}), |
@gtnx: The cost is similar to assigning a function expression to a prop: it updates at each render. |
We may use realue awesome HOCs on top of third parties components which have different various
onChange
signatures.The simplest case i can think is
onChange(value)
. For instance, this is the case for react-datetime or react-bootstrap-typeahead. In that case, we add the same hoc:Several ideas:
onChange
signature toonChange(value, payload)
.property
anditem
hoc provide on additional propsonChangeSimple
What do you think?
The text was updated successfully, but these errors were encountered: