react d3 : error Cannot read property 'string' of undefined

525 Views Asked by At

In reactd3, I get this error when I try to import:

var PieTooltip = require('react-d3-tooltip').PieTooltip;

How do I fix it?

TypeError: Cannot read property 'string' of undefined

  79 |   scaleExtent: [1, 10]
  80 | }, _commonProps2.default);
  81 | ChartSvg.propTypes = {
> 82 |   id: _react.PropTypes.string,

full error formatted

1

There are 1 best solutions below

0
On

Since version 15.5, PropTypes are moved to the package "prop-types" (as explained on https://reactjs.org/docs/typechecking-with-proptypes.html).

The last release of react-d3-core is based on React v0.14.7, so PropTypes were included in React at this time. If your app is using a more recent version of React, PropTypes cannot be taken directly from React.

This issue must be solved on the lib react-d3-core, but it seems to be no longer maintained. Either you correct the lib yourself, or you may try to include it manually (this might be a bit more complicated).