I get a backend data structure as following.
{
"courseDetails" :
[{"departmentId" : 105654,
"courses" :
[{"stream" : "science","courseIds" : ["104","105","106"]},
{"stream" : "art","courseIds" : ["102", "103"]}]
},
{"departmentId" : 105655,
"courses" :
[{"stream" : "commerce","courseIds" : ["101", "100"]}]
}
]
}
In the UI, I have three dropdown lists.
Department ID | Stream | Course ID
First Department ID dropdown list should be populated with departmentIDs 105654 and 105655. When department id 105654 is selected, Stream dropdown list should be populated as science and art. When science is selected from this second dropdown list, course ids should be populated in third dropdown list as 104, 105, 106.
The json data structure above is to have all data at once so that I don't have to make backend call each time a dropdown option is selected.
How can I achieve this using react js? I am new to it.