Currently following a guide right now to learn React and HTML and I'm at this part where we create a filter drop down and pass the selected item to the parent of it.
In the filter js file I have :
const dateFilterHandler = (event) => {
props.onChangeFilter(event.target.value);
}
and in the parent file, I have
const [filteredYear, setFilteredYear] = useState('2020')
const filterChangeHandler = selectedYear => {
setFilteredYear(selectedYear);
};
const dateFilterHandler = (selectedYear) => {
console.log("Expenses.js");
console.log(selectedYear);
};
Correct me if I'm wrong but is the child code, (filter) taking the value of the drop down and putting it into props, then the parent file is taking dateFilterHandler to use the value that was "lifted" up into it?