Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jptime committed Jul 31, 2020
1 parent 71802db commit 9b9ff91
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/ConnectedField.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function createConnectedField<L, M>(structure: Structure<L, M>) {
return this.ref.current
}

handleChange = (event: any) => {
handleChange = (eventOrValue: any) => {
const {
name,
dispatch,
Expand All @@ -94,7 +94,7 @@ function createConnectedField<L, M>(structure: Structure<L, M>) {
_reduxForm,
value: previousValue
} = this.props
const newValue = onChangeValue(event, { name, parse, normalize })
const newValue = onChangeValue(eventOrValue, { name, parse, normalize })

let defaultPrevented = false
if (onChange) {
Expand All @@ -103,21 +103,21 @@ function createConnectedField<L, M>(structure: Structure<L, M>) {
// to prevent the following error:
// `One of the sources for assign has an enumerable key on the prototype chain`
// Reference: https://github.com/facebook/react-native/issues/5507
if (!isReactNative && isEvent(event)) {
if (!isReactNative) {
onChange(
{
...event,
...(isEvent(eventOrValue) ? eventOrValue : (undefined: any)),
preventDefault: () => {
defaultPrevented = true
return eventPreventDefault(event)
return eventPreventDefault(eventOrValue)
}
},
newValue,
previousValue,
name
)
} else {
const onChangeResult = onChange(event, newValue, previousValue, name)
const onChangeResult = onChange(eventOrValue, newValue, previousValue, name)
// Return value of change handler affecting preventDefault is RN
// specific behavior.
if (isReactNative) {
Expand Down

0 comments on commit 9b9ff91

Please sign in to comment.