TextInput value is ignored (web)
See original GitHub issueCurrent 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:
- Created a year ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 typingaaaaaaaaabbbaaaaabbaaa
.Fixed by: https://github.com/callstack/react-native-paper/pull/3145