我在 JSX 中有一个react-stockchart图表示例:
JSX plunker: http://plnkr.co/edit/gist:b993d5fcc5c09dd66a6e?p=preview
我想将 JSX 添加到现有的 TypeScript 项目中,因此我将文件扩展名从 JSX 更改为 TSX 并从该站点进行了其他转换:http:
//slidedeck.io/thewazir/Using-Typescript-with-JSX
但问题仍然存在,这段代码无法编译:
CandleStickChartWithBollingerBandOverlay = fitWidth(CandleStickChartWithBollingerBandOverlay);
ReactDOM.render(<CandleStickChartWithBollingerBandOverlay data={data} type="hybrid"/>, document.getElementById("chart"));
fitWidth来源:https
://github.com/rrag/react-stockcharts/blob/master/src/lib/helper/fitWidth.jsx
如果我删除fitWidth它以不正确的宽度绘制:
ReactDOM.render(<CandleStickChartWithBollingerBandOverlay data={data} type="hybrid" width={800}/>, document.getElementById("chart"));
我试过这段代码,它不起作用(根本没有绘制任何东西):
var StockChartComponent = fitWidth(CandleStickChartWithBollingerBandOverlay);
ReactDOM.render(<StockChartComponent data={data} type="hybrid"/>, document.getElementById("chart"));
这也不起作用:
var StockChartComponent = fitWidth(new CandleStickChartWithBollingerBandOverlay());
ReactDOM.render(<StockChartComponent data={data} type="hybrid"/>, document.getElementById("chart"));