TextInput unable to take Text node as placeholder
See original GitHub issueDescription
When attempting to use a Text node as a placeholder of TextInput, the app throws an error (see screenshot). This is contrary to what is indicated by the docs, which states that placeholder is of type Node.
Reproduction
Sample Code:
import React, { Component } from 'react'
import { TextInput, Text } from 'react-native'
class App extends Component {
render() {
const myText = (
<Text style={{fontStyle:'italic', fontSize: 40}}>This is my placeholder</Text>
);
return (
<TextInput
placeholder={myText}
/>
)
}
}
export default (App)
For whatever reason, this problem presents itself when running via react-native run-<ios|android>
but is not seen when editing in the tutorial docs.
Solution
To address this issue, TextInput should actually be able to support taking a placeholder of type Node and rendering it.
Additional Information
- React Native version: Seen on both 0.37.0 and 0.41.2
- Platform: both
- Operating System: MacOS
Screenshots
ios | android |
---|---|
![]() |
![]() |
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
react-native TextInput placeholder not visible - Stack Overflow
I'm make simple screen contains only one ...
Read more >Placeholder property included in TextInput Componenent ...
Open project in device, turn on screenreader (e.g. TalkBack for Android, VoiceOver for iOS), and click the field. Click on field; Note that...
Read more >Don't Use The Placeholder Attribute - Smashing Magazine
For someone who has never encountered it before, placeholder text may look like entered content, causing them to skip over the input.
Read more >Text Input — Toga 0.2.15 documentation - Read the Docs
The text input widget is a simple input field for user entry of text data. ... This always returns a list, even if...
Read more >HTML DOM Input Text placeholder Property - W3Schools
The placeholder attribute specifies a short hint that describes the expected value of a text field (e.g. a sample value or a short...
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 Free
Top 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
It should not take a node. I was saying that it is possible that Facebook internally has an implementation that supports nodes for placeholders, but the OSS version only supports text.
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we’re automatically closing issues after a period of inactivity. Please do not take it personally!
If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.