Here is my code.
This is a form for filling in the request object attributes.
Expected Result
Users can select a technician from the drop-down box, and then the selected technician information will be stored in the request object.
The problem
My problem is the selected value does not show in the drop-down box.
What I want
I want the drop-down box component to be self-contained.
So, should I store the selected technician object in the reducer object in Technician.js? However, I just want to store the selected technician object in the HelpDesk.js only.
I don’t know why the selected technician object is not updated to the Technician.js.
Would you give me some advice on this issue?
2
Answers
It didn’t change because you were providing the select component with prop value. Just simply remove value and it will work fine or if you wanna give it a default value use defaultValue.
I’ve checked your code and I found the issue.
As you can see here, If the select is changed, the doChange() function will be called.
This is the doChange() function.
As you can see, you got the value of the select option like "e.value".
This is the issue. Because the data structure of "e.value" is an object.
Like this:
If you use "e.value.name" or "e.value.jobtitle", then it will work.
I wish this will help you. Good luck to you!!!