Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Having the code of a tooltip component + a triangle indicator around it, I am supposed to create a property within this component which allows my fellow developers to remove the indicator when necessary. However, the indicator is after my attempts still showing


demo.index.js

  return (
    <div>
      <h1>tooltip Demo</h1>

      <Tooltip
        title={"Text für Länge des Tooltips - noch länger"}
        body={
          <span>
            Test in Kursiv
          </span>
        }
        hide_indicator={true}
      >
        <button style={{ width: 200, margin: "0 auto" }}>Tooltip</button>
      </Tooltip>
    </div>
  );
};


What I have tried:

in the src.index.js I have created a function and the react.fragment in the return block taking up this function.

FUNCTION
handleIndicator = node => {
  this.setState({
    hide_indicator: false,
  });
};


RETURN BLOCK
render() {
    const { className, classes, light, isHtml, hideIndicator } = this.props;


...
hide_indicator={
           <React.Fragment>
             <span hide_indicator={true} ref={this.handleIndicator} />
           </React.Fragment>
         }
Posted
Comments
Andre Oosthuizen 16-Feb-22 4:37am    
In your return block you have "hideIndicator", throughout you have "hide_Indicator".
Member 15507303 17-Feb-22 13:51pm    
Thank you. In the meanwhile I could create the feature by making use of the given code in this manner:

{hide_indicator ? null : ( classNme = {classes.arrow} ref={this.handleArrowRef)}

Now I need to change this line using two classes which I'm supposed to create with css. So "null" is to become one class and the term in another class.

Like so:
{hide_indicator ? hideIndicatorClass : showIndicatorClass}

However, I struggle to retrieve the data from the written css classes. Whatever Boolean I choose for the prop "hide_indicator" in the App.js file, I only get to see one version of the two variations that is, "true" and "false" both yield no arrow indicator.

I tried various syntax changes, this one at least doesn't give me errors. Still, I am not sure whether it's correct. Maybe you can provide some more hints.

Anyway, thank you very much Andre

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900