onChange State Variant

What are you trying to do?

I have a couple of state variables:

  • setId
  • getId
  • setCatName
  • getCatName

I also have the following queries:

  • get All Categories
  • get Categories by the getId mapped to the id field
  • get Categories by the getCatName mapped to the CatName field

What I’m looking to do is that once when a Select Component which has the value of the Id and the Label of the CatName is selected; for it to update both the getId and getCatName fields. Once the getId or getCatName fields are changed, I’d like for the setId and setCatName fields to get updated.

I’m able to use the onChange interaction from the Select Component to update the getId variable from the value of the Select component. And since I have the get Id set as the query for the Get Category by Id, I can use that query’s catname result to update the getCatName.

What have you tried so far? (please link relevant docs and other forum posts)

Relevant links:

Hi, sorry I wasn’t able to understand your issue. One thing that is a bit weird in your example is that you have your state variables getId and setId, why can’t you just have id?