fix: use conditional require for echarts-wordcloud instead of dynamic import
Dynamic import was async and wordcloud plugin wasn't loaded before setOption was called. Now uses synchronous require() guarded by typeof window check to avoid SSR crash. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a359965bff
commit
fa8e2714ca
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import React, { useEffect, useRef } from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import * as echarts from 'echarts';
|
import * as echarts from 'echarts';
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
|
if (typeof window !== 'undefined') { require('echarts-wordcloud'); }
|
||||||
import { useThemeStore } from '@/adapters/state/zustand/themeStore';
|
import { useThemeStore } from '@/adapters/state/zustand/themeStore';
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
@ -41,11 +43,6 @@ export const EChartsBase: React.FC<EChartsBaseProps> = ({
|
||||||
const chartRef = useRef<echarts.ECharts | null>(null);
|
const chartRef = useRef<echarts.ECharts | null>(null);
|
||||||
const currentTheme = useThemeStore((s) => s.currentTheme);
|
const currentTheme = useThemeStore((s) => s.currentTheme);
|
||||||
|
|
||||||
// Load echarts-wordcloud plugin on client side only
|
|
||||||
useEffect(() => {
|
|
||||||
import('echarts-wordcloud').catch(() => {});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Init / re-init when theme changes
|
// Init / re-init when theme changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!containerRef.current) return;
|
if (!containerRef.current) return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue