I try to find solution how to handle events in React parent<->children components without external libraries.
Example, let's imagine we build Select (dropdown) component. Inside one parent component there are children components like leftIcon, Content, Tags, Search, OpenClose, List etc.
To pass only value I use Context and Reducer effects but I don't know how to pass events and handle it in parent component. Let's imagine there is a need to handle click event on all children.
First idea is to pass callback through props but from my perspective is not good. Second idea is to pass some how through Reducer's state callback and I didn't find any examples how it can be.
I appreciate any idea or solutions how to manage it. Thank you.
I also tried to create own EventEmitter to subscribe/unsubscribe but it was overmuch code.
UPD. Pass callback through components by props is normal practice. Let's imagine that there is something like nested components parent->child1->child2->child3->child4. There is a need to pass callback from parent to child4. Of course, It can be through props. But maybe there is more interested and simple solution.