Skip to content

Tooltip not re-rendering on state change #294

@jaredramirez

Description

@jaredramirez

Versions:
react-tooltip: 3.3.0
react: 15.4.2

Issue:
I have a tooltip that is rendering data from the state around it, to display an error message if a textfield is invalid.

render() {
  return (
    <input
      type={'text'}
      value={this.state.value}
      onChange={this.onTextChange}
      data-tip={this.state.errors[0]} // only show most significant error
      data-for={this.props.name}
      data-event={'focus'}
      data-event-off={'focusout'}
    />
    ...
    <ReactTooltip
      id={this.props.name}
      place={'bottom'}
      effect={'solid'}
      multiline={true}
    />
  );
}

As far at the focus events go, it works perfectly. However, when I revalidate the field and call

this.setState({
  errors: newArrayOfErrors,
});

the the tooltip does not updated.

I have tried

this.setState({
  errors: newArrayOfErrors,
}, () => ReactTooltip.rebuild());

and

componentDidUpdate() {
  ReactTooltip.rebuild());
}

but there is no difference in behavior.

Is there a way to include stateful data in the tooltip?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions