I'm using reactJS and I have here the choices for two select dropdown list names categories and items
constructor(props) {
super(props)
}
this.state = {
categories: [
{
"id": 1,
"category_name": "Powertools"
},
{
"id": 2,
"category_name": "Consumables"
}
],
items: [
{
"id": 1,
"item_name": "Grinder",
"category_id": 1
},
{
"id": 2,
"item_name": "Drill",
"category_id": 1
},
{
"id": 3,
"item_name": "Welding rod",
"category_id": 2
},
],
};
}
I'm trying to output the items dropdown list choices depending on the selected value of the categories dropdown list.
For example:
Dropdown 1 Selected Value: Powertools
Dropdown 2 choices: Grinder, Drill
Another example:
Dropdown 1 Selected Value: Consumables
Dropdown 2 choices: Welding rod
As of now, I've found this code snippet that does the thing that I want. Unfortunately, it's in a function component and I'm trying to convert it to a class component but with no success.
