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 unable to take Text node as placeholder

See original GitHub issue

Description

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
screen shot 2017-02-22 at 2 03 12 pm screen shot 2017-02-22 at 2 09 19 pm

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
brentvatnecommented, Feb 23, 2017

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.

0reactions
hramoscommented, Jul 25, 2017

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:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

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.

Read more comments on GitHub >

github_iconTop 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 >

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