Reputation: 73
Hi I'm new to react and trying to think about building up a component with a fly out menu that can be triggered from an element elsewhere in the DOM..
similar to the:
<button data-target="some-component-id">Click Me</button>
kind of approach from more traditional JS methods.. I was wondering if I was going to make it reusable i.e. you could have multiple components on the screen with remote activators.. what is the "react" style approach for something like this?
Thanks
Upvotes: 0
Views: 299
Reputation: 417
One approach would be to keep the status of the flyout menu (closed, open) as part of the application state. Every time you click the components that would need to trigger the menu, invoke an action that modifies the state of the flyout menu. The application state should be mapped to the component level state of flyout menu which would decide whether the menu should be open/closed state.
Upvotes: 2