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][iOS 11] - Does not change the text color without focus.

See original GitHub issue

Is this a bug report?

Yes, it seems like a Bug to me. Similar to #15650 and #14645

Changing the style has no effect. Only after the user focuses on the field does the color change.

iOS 9 works. iOS 10 not tested yet. iOS 11 not works.

Environment

Environment: OS: macOS Sierra 10.12.6 Node: 6.11.3 Yarn: 1.0.2 npm: 5.4.2 Watchman: 4.9.0 Xcode: Xcode 9.0 Build version 9A235 Android Studio: EAP AI-171.4333198 AI-171.4333198

Packages: (wanted => installed) react: 16.0.0-alpha.12 => 16.0.0-alpha.12 react-native: 0.48.4 => 0.48.4

The problem also exists in RN 0.46.4.

Steps to Reproduce

Create a component that contains a TextInpt and two Buttons that change the color.

class Example extends Component {
    state = {
        color: '#ff0000'
    }
    render() {
        const style = { color: this.state.color };
        return (
            <View style={{ marginTop: 20 }}>
                <TextInput style={style} value='Some Text Here' />
                <Button onPress={() => this.setState({ color: '#0000ff' })} title="Blue" />
                <Button onPress={() => this.setState({ color: '#ff0000' })} title="Red" />
            </View>
        )
    }
}

Expected vs Actual Behavior

textinput-color

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
douglasjuniorcommented, Oct 26, 2017

Changing the font size also “force” the color update.

class Example extends Component {
    state = {
        color: '#ff0000',
        fontSize: 28
    }
    componentDidMount() {
        Splash.hide();
    }
    render() {
        return (
            <View style={{ marginTop: 20 }}>
                <TextInput style={{ color: this.state.color, fontSize: this.state.fontSize }} value='Some Text Here' />
                <Button onPress={() => this.setState({ color: '#0000ff', fontSize: 28, })} title="Blue" />
                <Button onPress={() => this.setState({ color: '#ff0000', fontSize: 28.05 })} title="Red" />
            </View>
        )
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change the text color of text input in react native?
Show activity on this post. If you want to change the TextInput colour add a color in styles. Save this answer. Show activity...
Read more >
TextInput
A foundational component for inputting text into the app via a keyboard. ... in the text box that is a color, the background...
Read more >
UITextField | Apple Developer Documentation
There are two types of formatting you can do to a text field's text: You can change the font, color, and style of...
Read more >
Input
It is used for small, non-editable form fields that sit next to inputs and allows the size and height to align. It is...
Read more >
Focus and text fields
To give focus to a text field as soon as it's visible, use the autofocus property. ... TextField( autofocus: true, );. For more...
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