React query: running function after state change

how can I trigger a function whenever change in state happens
example
I’m passing a event handeling function to radio button component ,when I get back the which radio button is clicked
I want to change the content on the screen
which requires a function to re run

Components rerender every time the state changes, and they are functions, rerendering just means the function is being rerun. So anything you do in them will happen every time the state changes. If you pass a callback to the function down from the component you want to change, just run that callback when the state changes. Would be helpful to see a [preferably simplifies] example of what you’ve currently tried as it’s difficult to advise from just a small description.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.