Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing data to getContent #55

Open
JPags opened this issue Sep 27, 2017 · 2 comments
Open

Passing data to getContent #55

JPags opened this issue Sep 27, 2017 · 2 comments

Comments

@JPags
Copy link

JPags commented Sep 27, 2017

Is there a way to pass data to the getContent function so that I can create a single tooltip but then pass data from each place I use it to generate content?

@nijat13
Copy link

nijat13 commented Feb 8, 2018

Hi @JPags, did you find any solution?

@nijat13
Copy link

nijat13 commented Feb 8, 2018

We actually don't need any getContent. As It's redux-tooltip, we can use actions.
I've managed with creating an action that updates the content.

Let's use an origin example for more detailed information.

In examples/origin/app.js:

...
class App extends Component {
  constructor(props) {
    super(props);

    this.state = {
      color: "Red"
    }

    this.handleMove = this.handleMove.bind(this);
    this.handleLeave = this.handleLeave.bind(this);
  }
  ....
  componentDidMount() {
    let {color} = this.state;
    setInterval(() => {

      if (color === "Red"){
        color = "Black"
      }
      else {
        color = "Red"
      }

      this.setState({color});

      // ******* Dispatch the action that will change content
      this.props.dispatch({
        type: "redux-tooltip/CONTENT",
        payload: color
      })

    }, 2000);
  }
 ....

Check the full file.

Note: I was needed it onClick event.
Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants