Below is the code for my child functional component and parent functional component. The child component uses a library which gives me the reset function but the event where I need to call that reset function is in the parent component. Is their a way to call the child component function from parent component? I would appreciate if some one helps me with this.
import React from 'react';
export default function MyChildFunction() {
const {
Test
reset,
}
return (
<div style={{textAlign: 'center'}}>
<div style={{fontSize: '30px', color : 'white'}}>
<span>{Test}</span>:<span>{Test}</span>:<span>{Test}</span>
</div>
</div>
);
function handleReset() {
{reset()};
}
}
export default function NavBar({
return (
<div>
<MyChildFunction/>
</div>
)
}
import NavBar from "./components/NavBar";
function App() {
const changeUserState = (State) => {
alert(State);
MyChildFunction.handleReset(); -- here i want to have the function called.
setState(State);
};
return (
<>
<NavBar/>
</>
);
}