react-native-echarts | The react-naitve chart | Chart library
kandi X-RAY | react-native-echarts Summary
kandi X-RAY | react-native-echarts Summary
Echarts for react-native. The react-naitve chart.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of react-native-echarts
react-native-echarts Key Features
react-native-echarts Examples and Code Snippets
Community Discussions
Trending Discussions on react-native-echarts
QUESTION
I'm trying to use the following react-native-echarts-wrapper but in my projects all my components are made using hooks. So, when I have a state variable that changes its state I want to execute the function setOption(option)
where the option contains the state value.
The problem is that in the documentation the function setOption()
is referenced using this.chart.setOption(option)
. If I try to put without the this.
I get a message where chart
is undefined and if I only use function I get the message saying that setOption is not a function
.
So is there a way to get the reference of the chart component and its functions using RN Hooks?
Here is my code:
...ANSWER
Answered 2020-Oct-04 at 17:16You will have to use the 'useRef' hook to get access to the chart, even in the examples that are provided they use a reference to the chart and update it. I've made a basic example to change the background color which will give you the idea on how use the hook with the charts. Simply set the ref and use chart.current instead of this.chart.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-native-echarts
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page