I have something like :
onChangeText={(value) => setValue(value)}
important value is a global state because I need according to one condition to modify the value by another from an API call, the really unexpected problem arises when it comes to a long chain for example :
"In the Shadow of Young Girls in Flowers, published in 1913, second volume of In Search of Lost Time, won the Goncourt Prize in 1919. For Marcel Proust (1871-1922), it was the rebirth of a work"
onChangeText={(value) => { setValue(value) console.log('onChangeText value')
I observe 5 logs with a different translation :
"In the SIn the Shadow of Young Girls in Flowers, published in 1913, second volume of In Search of Lost Time, won the Goncourt Prize in 1919. For Marcel Proust (1871-1922), it was the rebirth of a work"
how is it possible for react to modify my value?
2
Answers
Thank you for your reply,
This morning while doing tests, I realized that it is the combination of multiline={true} and maxLength={200} which causes this bug, I will let you see this (you have to put yourself on IOS) : demo
Waiting for the api response could make the keyboard seem slow and since the user will still be able to type, when the api result finally was updated in state it would give you weird behavior. I think it would be better if you decoupled the global state from the textinput and only update it after the api call (demo):