以下是一个barChart
功能。它barChart
在屏幕上返回-
const barCharts = () => {
const fill = 'rgb(134, 65, 244)'
const data = [50, 10, 40, 95, -4, -24, null, 85, undefined, 0, 35, 53, -53, 24, 50, -20, -80]
return (
<View style={styles.sectionContainer}>
<BarChart style={{ height: 200 }} data={data} svg={{ fill }} contentInset={{ top: 30, bottom: 30 }}>
<Grid />
</BarChart>
</View>
);
};
我希望此barChart
组件在单击按钮时呈现。我当前的环境是react-native ios。单击App.js中的按钮后,如何完成渲染?
const BarCharts = () => {
const fill = 'rgb(134, 65, 244)'
const data = [50, 10, 40, 95, -4, -24, null, 85, undefined, 0, 35, 53, -53, 24, 50, -20, -80]
return (
<View style={styles.sectionContainer}>
<BarChart style={{ height: 200 }} data={data} svg={{ fill }} contentInset={{ top: 30, bottom: 30 }}>
<Grid />
</BarChart>
</View>
);
};
const OtherComponent = () => {
const [clicked, setClicked] = React.useState(false);
return <View>
<Button onClick={() => setClicked(!clicked)}>Click me</Button>
{clicked && <BarCharts />}
</View>
}
像这样的东西可能不是100%本机兼容的,但您应该可以对其进行调整。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句