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.

TextInput value is ignored (web)

See original GitHub issue

Current behaviour

When you for example filter the input state, the unfiltered input state is rendered.

Expected behaviour

The current value passed to the value prop is always rendered.

Code sample

const [value, setValue] = useState('');

// Renders react-native-paper instead of my-filtered-value when user types react-native-paper
const render = () => <TextInput value={value} onChangeText={(text) => setValue('my-filtered-value')} />

What have you tried

This seems to still work correctly in older versions (tested in 4.11.1).

Your Environment

software version
ios or android web
react-native latest
react-native-paper latest

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
seahorsepipcommented, Apr 6, 2022

Ended up being a small change related to controlled and uncontrolled inputs. Previously the props value was synced with local state in a useLayoutEffect but this causes an additional render and can get out of sync in cases where input is filtered.

In my usecase there was a props value that didn’t change while the input entered by the end user did change, the useLayoutEffect won’t be called and the local state gets out of sync with the props value.

One example would be value={value} onChangeText{text => setValue(text.replace(/./g, 'b'))} and a user typing aaaaaaaaabbbaaaaabbaaa.

Read more comments on GitHub >

github_iconTop Results From Across the Web

setting input type in dynamically created form is ignored
readonly and select are not valid type values.​​ I think i have a partial understanding of whats wrong. The readonly fields should not...
Read more >
TextInput
TextInput. A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, ...
Read more >
<input type="text"> - HTML: HyperText Markup Language | MDN
The value attribute is a string that contains the current value of the ... expression is applied and this attribute is ignored completely....
Read more >
HTML5 Forms: Value Attribute
The value attribute is not valid and ignored on the file input type. For select options, the value of the selected <option> gets...
Read more >
ion-input: Custom Input Value Type Styling and CSS ...
Inputs offer two options for clearing the input based on how you interact with it. The first way is by adding the clearInput...
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