peterp / react-native-tags

Tag input component for React Native
MIT License
288 stars 75 forks source link

TextField not displaying placeholder value #98

Open iyinolu opened 2 years ago

iyinolu commented 2 years ago

showLastTag function prevent placeholder from displaying on the input field. This is because the initial value of text in state is set to a whitespace instead of an empty string.

showLastTag = () => {
    this.setState(state =>
      ({
        tags: state.tags.slice(0, -1),
        text: state.tags.slice(-1)[0] || " "
      }),
      () =>
        this.props.onChangeTags && this.props.onChangeTags(this.state.tags)
    );
  };
joseito-terence commented 2 years ago

Set initialText=""

iyinolu commented 2 years ago

Yes, This works out. Although It works only when the field is first rendered. When all input values are cleared, the placeholder will not be visible.