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

Setting state on controlled TextInput duplicates its value #20361

Closed
2 of 3 tasks
DanielRamosAcosta opened this issue Jul 24, 2018 · 7 comments
Closed
2 of 3 tasks

Setting state on controlled TextInput duplicates its value #20361

DanielRamosAcosta opened this issue Jul 24, 2018 · 7 comments
Labels
Component: TextInput Related to the TextInput component. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@DanielRamosAcosta
Copy link

DanielRamosAcosta commented Jul 24, 2018

Environment

OS: Windows 10
Node: 10.6.0
Yarn: Not Found
npm: 6.1.0
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.1.0.0 AI-173.4819257

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: ~0.55.2 => 0.55.4

Description

I have created an app from scratch using create-react-native-app, and I have modified App.js to include the following:

import React from 'react';
import { StyleSheet, View, TextInput } from 'react-native';

export default class App extends React.Component {
  constructor () {
    super()
    this.state = {text: ''}
  }

  render() {
    return (
      <View style={styles.container}>
        <TextInput
          value={this.state.text}
          onChangeText={text => this.setState({text: text.toUpperCase()})}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    marginTop: 100
  },
});

Reproducible Demo

This is the example I'm using: https://snack.expo.io/HyVKGuVNQ

Here is a video I've recorded: https://www.youtube.com/watch?v=TyXIc2euVCs

It seems that it's only reproducible in Android

And here is the same video as GIF:

ezgif-4-8ecddfcd13

Why I haven't used react-native@0.56

Installing react-native@0.56 and react@16.4 leads to an strange error when executing npm start:

10:29:15: Failed building JavaScript bundle
10:29:16: You are now debugging remotely; check your browser console for your application logs.
10:29:16: (node:18920) UnhandledPromiseRejectionWarning: Error: Plugin/Preset files are not allowed to export objects, only functions. In E:\Documentos\Trabajo\LeanMind\my-appaaa\node_modules\babel-preset-expo\index.js
10:29:16:     at createDescriptor (E:\Documentos\Trabajo\LeanMind\my-appaaa\node_modules\@babel\core\lib\config\config-descriptors.js:162:11)
10:29:16:     at items.map (E:\Documentos\Trabajo\LeanMind\my-appaaa\node_modules\@babel\core\lib\config\config-descriptors.js:87:50)
10:29:16:     at Array.map (<anonymous>)
10:29:16:     at createDescriptors (E:\Documentos\Trabajo\LeanMind\my-appaaa\node_modules\@babel\core\lib\config\config-descriptors.js:87:29)
10:29:16:     at createPresetDescriptors (E:\Documentos\Trabajo\LeanMind\my-appaaa\node_modules\@babel\core\lib\config\config-descriptors.js:79:10)
10:29:16:     at presets (E:\Documentos\Trabajo\LeanMind\my-appaaa\node_modules\@babel\core\lib\config\config-descriptors.js:61:19)
10:29:16:     at presets (E:\Documentos\Trabajo\LeanMind\my-appaaa\node_modules\@babel\core\lib\config\config-descriptors.js:51:25)
10:29:16:     at mergeChainOpts (E:\Documentos\Trabajo\LeanMind\my-appaaa\node_modules\@babel\core\lib\config\config-chain.js:308:26)
10:29:16:     at E:\Documentos\Trabajo\LeanMind\my-appaaa\node_modules\@babel\core\lib\config\config-chain.js:271:7
10:29:16: (node:18920) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

Issues that might be related:

/cc @adrian-afergon

@DanielRamosAcosta DanielRamosAcosta changed the title Set value at TextInput gives unexpected behavior Setting state on controlled TextInput duplicates its value Jul 24, 2018
@react-native-bot react-native-bot added ⏪Old Version Component: TextInput Related to the TextInput component. labels Jul 24, 2018
@hramos
Copy link
Contributor

hramos commented Jul 24, 2018

Can you reproduce this on 0.56? You can try using react-native init instead to create a new project using 0.56.

@DanielRamosAcosta
Copy link
Author

DanielRamosAcosta commented Jul 25, 2018

@hramos The Error: Unable to resolve module AccessibilityInfo (reported at #14209) is blocking me 😢

@leo-tavares
Copy link

Hello @DanielRamosAcosta !

I've been through this same problem, The only solution I found was ... use the property autoCapitalize = {'characters'}.

I believe this is not the ideal solution, but it helps to "remedy" the problem.

@Noitidart
Copy link

I confirm I think this is related to - #19085

@react-native-bot
Copy link
Collaborator

I am closing this issue because it does not appear to have been verified on the latest release, and there has been no followup in a while.

If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here.

@react-native-bot react-native-bot added the Ran Commands One of our bots successfully processed a command. label Aug 23, 2018
@Noitidart
Copy link

It happens on the latest release as well.

@iagormoraes
Copy link

The problem of this is related to set uppercase the state string, maybe this can help the dev team of facebook to track the issue on native side.

@facebook facebook locked as resolved and limited conversation to collaborators Aug 23, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: TextInput Related to the TextInput component. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants