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

Doesn't accept target property #39

Closed
Revanth47 opened this issue Dec 21, 2018 · 1 comment
Closed

Doesn't accept target property #39

Revanth47 opened this issue Dec 21, 2018 · 1 comment

Comments

@Revanth47
Copy link

Revanth47 commented Dec 21, 2018

I am not able to add a target property to Tippy.

TypeScript has children property set to required but the native library also supports a target element.

Am I missing something here?

import React, { Component } from "react";
import Tippy from "@tippy.js/react";
import "tippy.js/dist/tippy.css";
import "./App.css";

class App extends Component {
  render() {
    return (
      <div className="App">
        <header className="App-header">
          
          <div className="target">Testing</div>
          <Tippy target=".target" content="Yaay works" />
        
        </header>
      </div>
    );
  }
}

export default App;
@atomiks
Copy link
Owner

atomiks commented Dec 21, 2018

Event delegation (target) doesn't really play nicely with React (the nature of React prefers encapsulated components) since it relies on the DOM for individual content too, but if you really want to use it, it still requires a child (it's used as the "delegate" parent wrapper which has the bubbling events attached to it).

import React, { Component } from "react";
import Tippy from "@tippy.js/react";
import "tippy.js/dist/tippy.css";
import "./App.css";

class App extends Component {
  render() {
    return (
      <div className="App">
        <header className="App-header">
          <Tippy content="Yaay works" target=".target">
            <div> {/* the parent wrapper which gets the event listeners */}
              <div className="target">Testing</div>
              <div className="target" data-tippy-content="Individual content">Testing</div>
              <div className="target">Testing</div>
            </div>
          </Tippy>
        </header>
      </div>
    );
  }
}

export default App;

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