Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

报错 Objects are not valid as a React child (found: object with keys {tag, attrs, children, text, key, elm}). If you meant to render a collection of children, use an array instead. This error is located at: #222

Open
984803909 opened this issue Dec 25, 2024 · 1 comment

Comments

@984803909
Copy link

Describe the bug
报错信息
Warning: Error: Objects are not valid as a React child (found: object with keys {tag, attrs, children, text, key, elm}). If you meant to render a collection of children, use an array instead.

This error is located at:

To Reproduce
Steps to reproduce the behavior:
1:index.tsx

import { SkiaChart, SVGRenderer } from '@wuba/react-native-echarts';
//import { SvgChart, SVGRenderer } from '@wuba/react-native-echarts';
import * as echarts from 'echarts/core';
import { useRef, useEffect } from 'react';
import {
BarChart,
} from 'echarts/charts';
import {
TitleComponent,
TooltipComponent,
GridComponent,
} from 'echarts/components';
import React from 'react';

// 注册扩展组件
echarts.use([
TitleComponent,
TooltipComponent,
GridComponent,
SVGRenderer,
// ...
BarChart,
])

const E_HEIGHT = 250;
const E_WIDTH = 300;

// 初始化
function ChartComponent({ option }:any) {
const chartRef = useRef(null);

useEffect(() => {
let chart: any;
if (chartRef.current) {
// @ts-ignore
chart = echarts.init(chartRef.current, 'light', {
renderer: 'svg',
width: E_WIDTH,
height: E_HEIGHT,
});
chart.setOption(option);
}
return () => chart?.dispose();
}, [option]);

// 选择你偏爱的图表组件
return ;
// return ;
}

// 组件使用
export default function PriceEcharts() {
const option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
},
yAxis: {
type: 'value',
},
series: [
{
data: [120, 200, 150, 80, 70, 110, 130],
type: 'bar',
},
],
}
return
}
2:package
"dependencies": {
"@expo/vector-icons": "^14.0.2",
"@gorhom/bottom-sheet": "^5.0.6",
"@react-native-community/datetimepicker": "8.2.0",
"@react-native-picker/picker": "2.9.0",
"@react-navigation/bottom-tabs": "^7.0.0",
"@react-navigation/native": "^7.0.0",
"@shopify/react-native-skia": "1.5.0",
"@wuba/react-native-echarts": "^2.0.2",
"echarts": "^5.5.1",
"expo": "~52.0.20",
"expo-blur": "~14.0.1",
"expo-constants": "~17.0.3",
"expo-font": "~13.0.2",
"expo-haptics": "~14.0.0",
"expo-linear-gradient": "~14.0.1",
"expo-linking": "~7.0.3",
"expo-router": "~4.0.14",
"expo-splash-screen": "~0.29.18",
"expo-status-bar": "~2.0.0",
"expo-symbols": "~0.2.0",
"expo-system-ui": "~4.0.6",
"expo-web-browser": "~14.0.1",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-native": "0.76.5",
"react-native-gesture-handler": "~2.20.2",
"react-native-modal-datetime-picker": "^18.0.0",
"react-native-picker-select": "^9.3.1",
"react-native-reanimated": "~3.16.1",
"react-native-safe-area-context": "4.12.0",
"react-native-screens": "~4.4.0",
"react-native-svg": "15.8.0",
"react-native-web": "~0.19.13",
"react-native-webview": "13.12.5",
"zrender": "^5.5.0"
},

This error is located at:

Expected behavior
我是用expo模拟器 之前一个项目可以正常加载 但是新项目就报这个错误

@zhiqingchen
Copy link
Member

提供一个可复现的仓库

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants