React-native-paper: TextInput label + placeholder mess

Created on 18 Oct 2018  路  3Comments  路  Source: callstack/react-native-paper

Having mess when setState fires and
props
value=""
placeholder="Placeholder"
label="Label"

demo_placholder

Your Environment

| software | version
| --------------------- | -------
| react-native-paper | ^2.1.2

Most helpful comment

code

import React, { Component } from 'react';
import { View, Keyboard } from 'react-native';
import { TextInput, Button } from 'react-native-paper';

export default class Settings extends Component {
  state = {
    error: null,
  };
  render() {
    const { error } = this.state;

    return (
      <View style={{ marginTop: 100 }}>
        <Button
          mode="contained"
          onPress={() => {
            Keyboard.dismiss();
            this.setState({ error: 'Required' });
          }}
        >
          Test
        </Button>
        <TextInput
          label="Email"
          placeholder="Placeholder"
          error={error}
        />
      </View>
    );
  }
}

Steps to reproduce:

  1. Press "test" button

All 3 comments

Can you post your code and steps to reproduce? Also can you try master if it still happens?

code

import React, { Component } from 'react';
import { View, Keyboard } from 'react-native';
import { TextInput, Button } from 'react-native-paper';

export default class Settings extends Component {
  state = {
    error: null,
  };
  render() {
    const { error } = this.state;

    return (
      <View style={{ marginTop: 100 }}>
        <Button
          mode="contained"
          onPress={() => {
            Keyboard.dismiss();
            this.setState({ error: 'Required' });
          }}
        >
          Test
        </Button>
        <TextInput
          label="Email"
          placeholder="Placeholder"
          error={error}
        />
      </View>
    );
  }
}

Steps to reproduce:

  1. Press "test" button

you can handle this by checking if there is an error or not on placeholder props like that:

<TextInput
          label="Email"
          placeholder={!error ? "Placeholder" : null}
          error={error}
        />
Was this page helpful?
0 / 5 - 0 ratings

Related issues

satya164 picture satya164  路  4Comments

mihaidaviddev picture mihaidaviddev  路  3Comments

yaronlevi picture yaronlevi  路  3Comments

navedar picture navedar  路  4Comments

timothystewart6 picture timothystewart6  路  4Comments