Skip to content

Commit

Permalink
feat(values): provide state to transformOnChange
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbonnet committed Jun 2, 2019
1 parent e5237ec commit 98cee83
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Sets `value` to `defaultValue` if `value` is `nil`.
> ⬇️ `{ value?, onChange? }`
Replaces `value` with the return value of `transformValue(value, previous?: { transformedValue, value })`, if set. Note that `previous` is not provided when the component first mounts, since there are no previous prop values.
Replaces `value` passed to `onChange(value, name, payload)` with the return value of `transformOnChange(value, name, payload)`, if set.
Replaces `value` passed to `onChange(value, name, payload)` with the return value of `transformOnChange(value, name, payload, previous: { transformedValue?, value? })`, if set.

#### `filterable`

Expand Down
4 changes: 2 additions & 2 deletions src/values.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function transformedOnChange(element) {
return (value, name, payload) => {
const { props } = element
return props.onChange(
props.transformOnChange(value, name, payload),
props.transformOnChange(value, name, payload, element.state),
name,
payload,
)
Expand All @@ -46,7 +46,7 @@ function transformedOnChange(element) {
export const transformable = (Component) =>
/*
Replaces `value` with the return value of `transformValue(value, previous: { transformedValue?, value? })`, if set. Note that `previous` is not provided when the component first mounts, since there are no previous prop values.
Replaces `value` passed to `onChange(value, name, payload)` with the return value of `transformOnChange(value, name, payload)`, if set.
Replaces `value` passed to `onChange(value, name, payload)` with the return value of `transformOnChange(value, name, payload, previous: { transformedValue?, value? })`, if set.
*/
setWrapperName(
Component,
Expand Down

0 comments on commit 98cee83

Please sign in to comment.