React-hook-form: [React Native] After form submit is returned object with nested value

Created on 7 Mar 2020  路  3Comments  路  Source: react-hook-form/react-hook-form

Describe the bug

_React Native_
From version 4.10.0 to latest version (now 5.0.0) after form submit is returned object with value:
{ text: { value: 'lorem ipsum' } }. Before 4.10.0 after submit returns { text: 'lorem ipsum' }

Additionaly on Expo on "Web" tab after type just one letter we have [object Object]

To Reproduce
Steps to reproduce the behavior:

  1. On Expo go to Android or iOS Tab (or just physical device with expo client)
  2. Type some text ie: 'lorem ipsum'
  3. Click on 'Submit'
  4. Look at the console

Expo links

Expected behavior
Return { text: 'lorem ipsum' } instead { text: { value: 'lorem ipsum' } }

question

Most helpful comment

hey from version 5, you can make onChange return simpler. I did make a mistake on the last v4, which was introduced this breaking change. I apologize for that.

const onChange = args => args[0].nativeEvent.text;

All 3 comments

hey from version 5, you can make onChange return simpler. I did make a mistake on the last v4, which was introduced this breaking change. I apologize for that.

const onChange = args => args[0].nativeEvent.text;

@bluebill1049
thanks for quick response, after change to const onChange = args => args[0].nativeEvent.text works now :)

it was a bug which I introduced on the initial version, and I thought i fixed it on the latest V4, then I realize it's a broken change this morning...

Was this page helpful?
0 / 5 - 0 ratings