Victory: Warning on unknown props since React 15.2.1

Created on 13 Jul 2016  路  2Comments  路  Source: FormidableLabs/victory

Here's the warning:

Warning: Unknown props `lineHeight`, `events`, `slice`, `text`, `index`, `datum`, `verticalAnchor`, `angle` on <text> tag.

Do you know how I could filter these props?

Most helpful comment

I'm getting similar warnings for <VictoryGroup>:

Warning: Unknown props `parent`, `events` on <g> tag. Remove these props from the element. For details, see https://fb.me/react-unknown-prop
    in g
    in VictorySharedEvents (created by VictoryGroup)
    in VictoryGroup (created by VictoryChart)
    in g
    in svg (created by VictoryContainer)
    in VictoryContainer (created by VictoryChart)
    in VictoryChart (created by MyOwnGraphComponent)

All 2 comments

I'm getting similar warnings for <VictoryGroup>:

Warning: Unknown props `parent`, `events` on <g> tag. Remove these props from the element. For details, see https://fb.me/react-unknown-prop
    in g
    in VictorySharedEvents (created by VictoryGroup)
    in VictoryGroup (created by VictoryChart)
    in g
    in svg (created by VictoryContainer)
    in VictoryContainer (created by VictoryChart)
    in VictoryChart (created by MyOwnGraphComponent)

I think the simplest way would be to just check if the default element is being used (like the <g> in case of VictorySharedEvents set in defaultProps), and filter out all the superfluous props.

Something like:

getContainer(props, children) {
  ...
  if (!this.props.container) {
    usingDefaultComponent = true;
  }
  const container = this.props.container || this.props.groupComponent;
  ...
  return React.cloneElement(
      container,
      assign(
        {}, parentProps, usingDefaultComponent ? {} : {events: Events.getPartialEvents(parentEvents, "parent", parentProps)}
      ),
      children
    );
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

seddonm1 picture seddonm1  路  5Comments

esutton picture esutton  路  6Comments

captDaylight picture captDaylight  路  5Comments

michowski picture michowski  路  4Comments

danielberndt picture danielberndt  路  4Comments