question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[0.54] TextInput.setNativeProps({text: ''}) no longer works

See original GitHub issue

Environment

Environment:
  OS:  macOS Sierra 10.12.6
  Node:  8.7.0
  Yarn:  1.3.2
  npm:  5.6.0
  Watchman:  4.7.0
  Xcode:  Xcode 9.2 Build version 9C40b
  Android Studio:  3.0 AI-171.4443003

Packages: (wanted => installed)
  react: ^16.3.0-alpha.1 => 16.3.0-alpha.1
  react-native: 0.54.0 => 0.54.0

Expected Behavior

Calling textInputRef.setNativeProps({text: ''}) or textInputRef.clear() clears the text input – this was working in previous versions (before the <Text> rewrite in 0.54).

Actual Behavior

Calling textInputRef.setNativeProps({text: ''}) or textInputRef.clear() does nothing.

Steps to Reproduce

Repro here: https://github.com/Leeds-eBooks/react-native-0.54-text-input-clear-repro

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:35
  • Comments:23 (3 by maintainers)

github_iconTop GitHub Comments

27reactions
padvladcommented, May 16, 2018

I am using v0.55.3 and I’ve encountered the same issue. textInputRef.clear() and textInputRef.setNativeProps({text: ''}) only seem to work on Android. On iOS nothing happens.

21reactions
x3388638commented, May 30, 2018

v0.55.3 a dirty solution for iOS

if (Platform.OS === 'ios') {
	this.textInputRef.setNativeProps({ text: ' ' });
}

setTimeout(() => {
	this.textInputRef.setNativeProps({ text: '' });
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Direct Manipulation - React Native
setNativeProps is the React Native equivalent to setting properties directly on a DOM node. Use setNativeProps when frequent re-rendering ...
Read more >
React Native - TextInput.setNativeProps isn't triggering ...
I am trying to clear a text input using setNativeProps({ text: '' }) which according to the documentation is a common way to...
Read more >
react native textinput ref value - You.com | The AI Search ...
The value to show for the text input. TextInput is a controlled component, which means the native value will be forced to match...
Read more >
Unable to setNativeProps the style in <text> component - Reddit
setNativeProps () is not working, everytime i try to change the Text style ... }>as</Text> <TextInput ref={ refUser } style={ [styles.input] ...
Read more >
TextInput · React Native Paper
A component to allow users to input text. ... Active underline color of the input. outlineColor ... The number of lines to show...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found