I want to clear user's input data in a one component from button click event in another component. Component structure looks like bellow :
Search (contains Reset button)
|
Tabs
|
------------------
| | |
Student Subject Lecturer > (These components contains their own Rest fucntions)
HTML elements in the selected tab should clear data when Reset button is clicked. Each tab component(Student, Subject, Lecturer) contains related UseStates and Reset function(ResetStudent(), ResetSubject()).
How can I achieve this using ReactHooks ?
<Search>
<Tabs/>
<button type="button">Search</button>
<button type="button">Reset</button>
</Search>
Sample code look like below :
function Search() {
return (
<div className="App">
<TabsComponent/>
<button type="button">Search</button>
<button type="button">Reset</button>
</div>
);
}
export default Search;
function TabsComponent() {
return (
<div >
<Student/>
<Subject/>
</div>
);
}
export default TabsComponent;
function Student() {
return (
<div >
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname">
</div>
);
}
export default Student;