Skip to content
Advertisement

Refresh data through a new GET request – React Dropdown

I have this Dropdown Menu (done with MUI) which allows to choose the day value. When it changes, I’d like it to make a new GET request with the new parameter, but I don’t know how to do it as it uses useEffect.

My function to fetch data

JavaScript

My dropdown menu :

JavaScript

Advertisement

Answer

You can add day as dependency in useEffect. So that when day value is changed, automatically useEffect will be executed.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement