mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
26aa27da63
Summary: Autocorrect was broken for controlled TextInput components by a change to batch event handling in React Native: https://github.com/facebook/react/commit/9f11f8c2634921e657df2691e6bfda18fead5bcc For example, a TextInput like this would be affected by this bug: ```javascript <TextInput autoCorrect={true} style={{height: 26, width: 100}} onChangeText={(text) => this.setState({ text })} value={this.state.text} /> ``` This fix uses the same approach as https://github.com/facebook/react-native/commit/0cd2904b235f53ed684bb9898280461e2cee0b5b The problem is that TextInput's _onChange handler relied on this.props.value being updated synchronously when calling this.props.onChangeText(text). However, this assumption was broken when React Native event handling started being batched. The fix is to move the code that relies on this.props.value being up-to-date to componentDidUpdate. **Test plan (required)** Tested autocorrect now works on iOS in a small app and a large app. Also tested t Closes https://github.com/facebook/react-native/pull/7676 Differential Revision: D3346221 Pulled By: nicklockwood fbshipit-source-id: 715df3e8a03aa58cb0a462de4add02289d42782f