I have one function
const getData=()=> { }
declared in dashboard
component.
I want to call this function in another component called Testing
Previously I tried using props but getting error getData() is not a function.
And the getData()
function is showing unused in dashboard
component.
I have one parent component named ChatBot
.
How can I call this getdata()
function from dashboard
component to testing
component by using usestate
or useeffect
.
2
Answers
Try moving your getData() function out of dashboard to separate lets say utility file, and from their import it in both dashboard and testing
OR
A better way would be to declare it in chatbot component, probably you did some mistake while implementing it.
There are certain ways for achieving this :