How to set text to a new value (case: dropdown menu) I am working on a dropdown component that updates the ‘select option’ text with the option text that receives the click. So, if the user selects ‘apple’ from the list, the dropdown would show ‘apple’ as the selected option. One approach would be to use variables inside the component. To continue with our example, we would store ‘apple’ as a variable and wire it up to one of the options in the dropdown list. The ‘select option’ would be set to ‘apple’ when the user selects it. The problem with this approach is that a variable can only be defined once. As a result, multiple instances will all refer to the same value.
For example, if I want to use two dropdown components, one with a list of fruits and another with a list of car brands, this is not possible.
An alternative approach is to link the variables to the option texts at the instance level instead of the component level. This way, each dropdown would have its own set of variables. However, when setting up these events