1- import React , { forwardRef , useLayoutEffect , useRef } from 'react' ;
1+ import React from 'react' ;
2+ import type { ComposeOption , GridComponentOption } from 'echarts' ;
23import {
34 LineChart as EChartLineChart ,
45 PieChart as EChartPieChart ,
56 type LineSeriesOption ,
67 type PieSeriesOption ,
78} from 'echarts/charts' ;
8- import type { ComposeOption } from 'echarts/core' ;
9- import { GridComponent , type GridComponentOption } from 'echarts/components' ;
9+ import { GridComponent } from 'echarts/components' ;
1010import type { ComponentOption } from 'echarts/types/src/util/types.js' ;
1111import {
1212 ChartContext ,
@@ -48,20 +48,20 @@ interface ChartComponentType<T extends ComponentOption> {
4848}
4949
5050function defineChart < T extends ComponentOption > ( ext : EChartExt ) {
51- const ChartComponent = forwardRef (
51+ const ChartComponent = React . forwardRef (
5252 (
5353 { className, style, containerProps, compose, children, ...props } : ChartBaseProps < any > ,
5454 ref : React . ForwardedRef < echarts . ECharts >
5555 ) => {
56- const containerRef = useRef < HTMLDivElement > ( null ) ;
57- const chartRef = useRef < echarts . ECharts | null > ( null ) ;
56+ const containerRef = React . useRef < HTMLDivElement > ( null ) ;
57+ const chartRef = React . useRef < echarts . ECharts | null > ( null ) ;
5858 const ctx = useInitialChartContext ( ) ;
5959
6060 useRegister ( ( echarts ) => {
6161 echarts . use ( [ ext , compose ?. map ( ( comp ) => comp . ext ) . flat ( ) || [ ] ] . flat ( ) ) ;
6262 } ) ;
6363
64- useLayoutEffect ( ( ) => {
64+ React . useLayoutEffect ( ( ) => {
6565 const chart = ( chartRef . current = echarts . init ( containerRef . current , null ) ) ;
6666 assignForwardedRef ( ref , chart ) ;
6767 return ( ) => {
@@ -70,7 +70,7 @@ function defineChart<T extends ComponentOption>(ext: EChartExt) {
7070 } ;
7171 } , [ ] ) ;
7272
73- useLayoutEffect ( ( ) => {
73+ React . useLayoutEffect ( ( ) => {
7474 const chart = chartRef . current ;
7575 if ( ! chart ) return ;
7676 for ( const opt of ctx . options ) chart . setOption ( opt , defaultSetOptionOpt ) ;
0 commit comments