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] when use secureTextEntry=true in TextInput, can't modify textInput's text color

See original GitHub issue

Environment

react-native info

React Native Environment Info:
    System:
      OS: macOS 10.14.1
      CPU: (4) x64 Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz
      Memory: 2.15 GB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.12.0 - /usr/local/bin/node
      Yarn: 1.10.1 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 26, 27, 28
        Build Tools: 26.0.3, 27.0.3, 28.0.3
        System Images: android-26 | Google APIs Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728 
      react-native: 0.57.4 => 0.57.4 
    npmGlobalPackages:
      react-native-cli: 2.0.1

package.json

{
  "name": "TemReactNative",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.6.0-alpha.8af6728",
    "react-native": "0.57.4"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.49.0",
    "react-test-renderer": "16.6.0-alpha.8af6728"
  },
  "jest": {
    "preset": "react-native"
  }
}

Description

when I use secureTextEntry=true, I can’t change the text color dynamically,

2018-11-08 16 37 01

when I use secureTextEntry=false, it’s my expect ,but I can’t understand why secureTextEntry=true is wrong 2018-11-08 16 40 37

Reproducible Demo

the code is

react-native init AwesomeProject
cd AwesomeProject
react-native run-ios
import React, { Component } from 'react'
import { TextInput, View } from 'react-native'

class TestTextInputSecureTextEntry extends Component {
  constructor(props) {
    super(props)
    this.state = {
      value: ''
    }
  }
  render() {
    const { value } = this.state
    const color = value === '123456' ? 'green' : value==='1234' ? 'red' : 'black'
    console.log('this.state.value:',this.state.value)
    console.log('color:',color)
    return (
      <View style={{ backgroundColor: '#ccf', justifyContent: 'center', alignItems: 'center',flex:1 }}>
        <TextInput
          // selectionColor={color}
          style={{ color: color, borderBottomWidth: 1, borderColor: color,width:'100%' }}
          secureTextEntry={true}
          value={value}
          onChangeText={text => {
            this.setState({ value: text })
          }}
        />
      </View>
    )
  }
}

export default TestTextInputSecureTextEntry

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
ericlewiscommented, Feb 28, 2019

Fixed: #23524.

2reactions
todoronecommented, Jun 17, 2019

@ericlewis Fix You provided did not fix this issue, please reopen it as it’s still relevant. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change the font family of a TextInput ... - Stack Overflow
My email field style would appear perfect but the password font style would change ... And adding adding ref={inputRef} to the TextInput as...
Read more >
TextBox Class (Windows.UI.Xaml.Controls) - Microsoft Learn
You can use a TextBox control to display and edit unformatted text. ... Colors.Beige); textBox.Foreground = new SolidColorBrush(Windows.UI.Colors.
Read more >
TextInput - React Native
The most basic use case is to plop down a TextInput and subscribe to the ... in the text box that is a...
Read more >
Text input | U.S. Web Design System (USWDS)
Text input. A text input allows users to enter any combination of letters, numbers, or symbols. Text input boxes can span single or...
Read more >
A complete guide to TextInput in React Native - LogRocket Blog
Learn how to implement React Native's TextInput component, customize it to collect user inputs, and style your fields with React Native ...
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