Skip to content
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

asyncValidate doesn't get the value from blurred field on React Native #4716

Open
JoaoMosmann opened this issue Feb 5, 2021 · 2 comments
Open
Labels

Comments

@JoaoMosmann
Copy link

Subject of the issue

asyncValidate doesn't get the value from blurred field on React Native.

Your environment

Software Version(s)
redux-form ^8.3.7
redux ^4.0.4
react-redux ^7.2.1
react 16.9.0
react-native 0.61.2
node 12.13.0
yarn if using 1.22.10
Browser native
Operating System android

Steps to reproduce

On a react-native environment
Create a form with a TextField.
On reduxForm() setup like:

reduxForm({
  name: 'formName',
  asyncBlurFields: ['fieldName'],
  asyncValidate: async (values, dispatch, props) => {
    console.log({ values });
    // fieldName will be undefined 
  }
})

Expected behaviour

On blurring a TextField, the asyncValidate function should be called with the field value

Actual behaviour

On blurring the field, the asyncValidate function will be triggered, but the value will be undefined

Other information

The root of the cause seems to be on the file ConnectedField.js line 176. The onChangeValue returns undefined as the getValue tries to read the variable event.nativeEvent.text which does not exist on the blur event.

@JoaoMosmann JoaoMosmann added the bug label Feb 5, 2021
@alexjavier15
Copy link

The same when using Parser.

@ranvirgorai
Copy link

ranvirgorai commented Jul 12, 2021

Facing same issue with below are package version
"react": "16.11.0",
"react-native": "0.62.2",
"react-redux": "7.2.0",
"redux": "^4.0.5",
"redux-form": "8.3.6"

Observation 1 : the fields which are passing in asyncBlurFields, have undefined value, getting rest all values of form,
if using asyncChangeFields instead of asyncBlurFields I am getting values as expected on change, but I need all form values on blur.

Observation 2 : if there is multiple filedName passed in asyncBlurFields, for current active filed is empty but getting rest form values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants