react-highcharts: ReferenceError: document is not defined

doc = document,
                  ^
ReferenceError: document is not defined

Seems to be an issue when trying to run this using an isomorphic app

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 23 (11 by maintainers)

Most upvoted comments

With the help of @Kureev I seem to hack a (hacky) fix

import React from 'react';

export default class HighchartGraph extends React.Component {

    render() {
      let graph;

      if(window === undefined) {
        graph = (<div></div>);
      } else {
        var Highcharts = require('react-highcharts/more');
        graph = (<Highcharts config={this.props.chartData}></Highcharts>)
      }

      return (
          <div>
            {graph}
        </div>
      );
    };
}

This seems to have fixed the issue. I would still love to see @0xCMP custom component though 😃