AtlasKit DropdownMenu: How to Manage State?

Hi, I am trying to develop a filtering table using the AtlasKit DropdownMenu component as the filter(s). The documentation is fairly good, but doesn’t really describe how to get the state of the DropdownMenu or handle when it changes. How can I update state when something has been selected? Just use an onClick handler on each of the DropdownItem components? It looks like the DropdownMenu used to utilize a method called “onItemActivated”, but this has been deprecated. The examples don’t give any indication on how we should be using this in conjunction with other components. The docs don’t seem to refer to any kind of state management either.

Thanks for your time.

Hey @GregTaylor, have a look at this example I made for you:

You’d use the onClick attribute to trigger a function and send the current selection object. That function will sit above the render declaration but within the React Class. This function when run will update the state selectedProject which was declared in the Class constructor. The selectedProject state variable also gets declared in the class render and then used to populate the table under the dropdown.

Hope this helps


Hi Biro,

Thanks for the help! This is the path I ended up going down; it’s good to hear that it was the right one!


1 Like