unable to use highchart with react 18
Parth1508 opened this issue · comments
while implementing Highchart for my project where im using react 18 with Typescript. I'm getting the error :
./node_modules/highcharts/highcharts.js 292:100
Module parse failed: Unexpected token (292:100)
File was processed with these loaders:
- ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| let r = !e;
| return t.forEach(t => {
if (t.length > 1) for (o = t.length - 1; o > 0; o--) (s = t[o] - t[o - 1]) < 0 && !r ? (e?.(), e = void 0) : s && (void 0 === i || s < i) && (i = s);
| }), i;
| },
while npm run start
Code Snippet :
import React, { useRef } from 'react';
import * as Highcharts from 'highcharts';
import HighchartsReact from 'highcharts-react-official';
const options: Highcharts.Options = {
title: {
text: 'My chart'
},
series: [{
type: 'line',
data: [1, 2, 3]
}]
};
const HighchartDemo = (props: HighchartsReact.Props) => {
const chartComponentRef = useRef<HighchartsReact.RefObject>(null);
return (
<HighchartsReact
highcharts={Highcharts}
options={options}
ref={chartComponentRef}
{...props}
/>
);
};
export default HighchartDemo
Hi @Parth1508,
Thank you for contacting us!
I've tried to reproduce the issue, but everything seems to work fine with the newest Highcharts and React 18. Could you create a minimal project with problem reproduction and add it here as rar archive?
Best regards!
@Parth1508 I'm not a contributor so look to ppotaczek first, but could you share your package.json? I'm also curious if you're using vite.