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

Static member defaultEvents on VictoryTooltip is not in TypeScript typings #1549

Closed
Zeddox opened this issue Apr 30, 2020 · 1 comment · Fixed by #1751
Closed

Static member defaultEvents on VictoryTooltip is not in TypeScript typings #1549

Zeddox opened this issue Apr 30, 2020 · 1 comment · Fixed by #1751
Assignees
Labels
Note: Good first issue 🤩 Good issue for new contributors Type: Bug 🐛 Oh no! A bug or unintentional behavior

Comments

@Zeddox
Copy link

Zeddox commented Apr 30, 2020

Following the Custom Tooltip Labels example in a TypeScript project leads to a compiler error.

The type definition file for VictoryTooltip doesn't export with this static member included.

@boygirl boygirl added Type: Bug 🐛 Oh no! A bug or unintentional behavior Note: Good first issue 🤩 Good issue for new contributors labels Oct 8, 2020
@becca-bailey becca-bailey self-assigned this Dec 1, 2020
@becca-bailey
Copy link
Contributor

becca-bailey commented Dec 1, 2020

Thanks for reporting this!

The type of this CustomLabel component is just a React.Component, which in Typescript doesn't allow static properties to be set after initialization.

We can fix this by moving the static property inside the class like this.

class CustomLabel extends React.Component {
  static defaultEvents = VictoryTooltip.defaultEvents;

  render() {
    return (
      <g>
        <VictoryLabel {...this.props} />
        <VictoryTooltip
          {...this.props}
          x={200}
          y={250}
          orientation="top"
          pointerLength={0}
          cornerRadius={50}
          flyoutWidth={100}
          flyoutHeight={100}
          flyoutStyle={{ fill: "black" }}
        />
      </g>
    );
  }
}

I'll also push an update to add the static property defaultEvents to the VictoryTooltip type definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Note: Good first issue 🤩 Good issue for new contributors Type: Bug 🐛 Oh no! A bug or unintentional behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants