Dropdown not working inside Array.map()
See original GitHub issueExact same component is working outside the loop but not working inside the Array.map function, as required to loop through a list of drop-down array.
- components:
Dropdown
- reactstrap version
#5.0.0-beta
- import method
es
- react version
#16.2.0
- bootstrap version
#4.0.0
What is happening?
I have a array of data that generates a new dropdown via looping but the dropdown is not working inside the loop but if I cut paste the code snippet outside the loop the dropdown stops working. It Displays the button but nothing happens when clicked.
What should be happening?
It should display the other options in the dropdown list.
Error message in console
No Error in Console.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Dropdown menu not showing when mapping through array ...
I am working on a Laravel project that implements ReactJS on the front end and I'm trying to create a drop down menu...
Read more >How to Convert react-dropdown-select's Default Value from ...
The snippet above helps us place the value key into an entirely new array since that is what we need, and this is...
Read more >Customize a reusable React dropdown menu component
In the code above, when populating the location array, we have a unique id to use with a key prop of map method....
Read more >How to Create a Dropdown List with Array Values using ...
Here we will populate the dropdown list with an array. Below is the description of popular approaches used in JavaScript. Example 1: In...
Read more >Controls | Maps JavaScript API - Google Developers
The Map Type control is available in a dropdown or horizontal button bar style, ... Some controls appear on the map by default...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
UncontrolledDropdown
works the same way asDropdown
you just don’t provide theisOpen
andtoggle
props. If you need either one of those (to gain more control), you’ll have to useDropdown
directly. Dropdowns don’t really “change”, they are not like<select>
, they don’t have a value. They are primarily for displaying lists of links and such as noted by bootstrap:Because of that, there is no nice way to determine which item was selected. (the same goes for bootstrap.js itself) If you need to determine which item was selected to take action, you can add individual event listeners on the items to determine which one is being clicked. Or Dropdown’s toggle callback should be passed the event which triggered it, which you can use to determine which item was selected (if any) to trigger the toggle (it’s more advanced)
@TheSharpieOne Thanks for the Prompt response. I think Dropdown should have a onChange callback with the id of the selected option. It a more realistic scenarios to implement a dropdown.
It The addon callback will really help a lot other writing a lot of code in developer side.