codesuki / react-d3-components

D3 Components for React
http://codesuki.github.io/react-d3-components/example.html
MIT License
1.63k stars 205 forks source link

Warning: React.renderToString is deprecated #83

Closed mikechabot closed 8 years ago

mikechabot commented 8 years ago

I'm using LineChart with ReactJs (0.14.5). Everything is displaying appropriately, and here's my component:

<LineChart
    data={data} 
    width={500} 
    height={250} 
    margin={{top: 10, bottom: 40, left: 25, right: 10}} />

However, I am getting the following warnings in console via warnings.js:

Warning: React.renderToString is deprecated. Please use ReactDOMServer.renderToString from require('react-dom/server') instead.
Warning: LineChart.getDOMNode(...) is deprecated. Please use ReactDOM.findDOMNode(instance) instead

The first warning is stemming from LineChart.js, line #60:

var rect = React.renderToString(React.createElement("rect", { width: width, height: height }));
thomasmodeneis commented 8 years ago

Hi, I was also with this problem: [10:45:25] Warning: React.renderToString is deprecated. Please use ReactDOMServer.renderToString from require('react-dom/server') instead.

I've solved it by following what it says and replacing from: React.renderToString(React.createElement(Router, i));

To ReactDOM.renderToString(React.createElement(Router, i));

codesuki commented 8 years ago

I'll make a small fix for this. Thanks for reporting!

thomasmodeneis commented 8 years ago

Thanks for this amazing d3-components :) Cheers

mikechabot commented 8 years ago

Thanks! I second the sentiment of @thomasmodeneis - great stuff!

codesuki commented 8 years ago

Thank you! I uploaded a new npm release with the problem fixed. Maybe you can check it out!

mikechabot commented 8 years ago

Confirmed working as expected

codesuki commented 8 years ago

Thanks for the feedback!