question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem: fixWidth.jsx throws Invariant Violation in React v15

See original GitHub issue

invariant.js:39 Uncaught Invariant Violation: traverseParentPath(…): Cannot traverse from and to the same ID, ``.

Code to reproduce

import React from "react";
import d3 from "d3";

import ReStock from "react-stockcharts";

var {ChartCanvas, Chart} = ReStock;

var {CandlestickSeries} = ReStock.series;
var {XAxis, YAxis} = ReStock.axes;
var {fitWidth} = ReStock.helper;

class CandleStickChart extends React.Component {
  render() {
    const {type, width, data} = this.props;
    return (
      <ChartCanvas width={width} height={400}
                   margin={{left: 0, right: 0, top:25, bottom: 30}} type={type}
                   data={data}
                   seriesName='CandleStick'
                   xAccessor={d => d.date} xScale={d3.time.scale()}>

        <Chart id={1} yExtents={d => [d.high, d.low]}>
          <XAxis axisAt="bottom" orient="bottom" ticks={6} stroke="none" tickStroke="#9E9E9E"/>
          <YAxis axisAt="left" orient="right" ticks={10} stroke="none" tickStroke="#9E9E9E"/>
          <CandlestickSeries fill={d => d.close > d.open ? "#32c2b0" : "#EDB24E"}/>
        </Chart>
      </ChartCanvas>
    );
  }
}

CandleStickChart.propTypes = {
  data: React.PropTypes.array.isRequired,
  width: React.PropTypes.number.isRequired,
  type: React.PropTypes.oneOf(["svg", "hybrid"]).isRequired,
};

CandleStickChart.defaultProps = {
  type: "svg"
};
CandleStickChart = fitWidth(CandleStickChart);

export default CandleStickChart;

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tommileycommented, Apr 27, 2016

This happens when using npm, react-stockcharts is loading the older version of react and its conflicting with 15.0.1. Once react-stockcharts is updated to depend on 15.0.1 it should resolve the issue.

0reactions
rragcommented, Jul 27, 2016

fixed, published in 0.5

Read more comments on GitHub >

github_iconTop Results From Across the Web

React App is not coming up. Error:INvariant Violation
Throws error: Invariant Violation Element type is invalid: expected a string (for built-in components) or a class/function (for composite ...
Read more >
Invalid Hook Call Warning - React
You are probably here because you got the following error message: Hooks can only be called inside the body of a function component....
Read more >
Understanding the "Objects are not valid as a react child" Error ...
The problem starts when myVariable assumes an object. React has no way to tell what to render when provided with an object, thus...
Read more >
Invariant Violation: Failed to call into JavaScript module ...
ERROR Invariant Violation : Failed to call into JavaScript module method AppRegistry. ... error when loading React Native., js engine: hermes ...
Read more >
Troubleshooting common React Native bugs - LogRocket Blog
Dependencies error. Import error. Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found