kusti8 / proton-native

A React environment for cross platform desktop apps
https://proton-native.js.org
MIT License
10.92k stars 360 forks source link

TextInput Cursor keep reset to starting position when setState, #287

Open Taymindis opened 4 years ago

Taymindis commented 4 years ago

Describe the bug TextInput Cursor keep reseting to first position when setState on event of changeText,

To Reproduce

<View style={{ flex: 1, flexDirection: 'column' }}>
            <TextInput
              onBlur={() => {
                console.log('blur');
              }}
              onChangeText={text => {
                this.setState({ text });
              }}
              value={this.state.text}
              style={{ flex: 1 }}
              multiline
            />
          </View>

Expected behavior It should be back to the position where it lay

HassanA14 commented 3 months ago

I had the same issue. All you have to do is remove value={this.state.text} from your <TextInput /> component. For example:

<View style={{ flex: 1, flexDirection: 'column' }}>
            <TextInput
              onBlur={() => {
                console.log('blur');
              }}
              onChangeText={text => {
                this.setState({ text });
              }}
              style={{ flex: 1 }}
              multiline
            />
          </View>