reactjs - Should/can I pass JSX components that do not render? -


i've seen in multiple libraries built on react now, passing jsx components defining functionalities, not immediate html output, seems accepted.

for example (maybe bad one) react-router defines routes using jsx components, though routes rather define configuration instead of rendering.

i have situation want attach tree of actions (like sub menus) multiple types of components. there menu component outputs button context menu, have pass same set of actions different trigger, that, maybe, renders whole different set of elements reflect actions.

my idea create jsx component defines action child actions , never renders directly, used parent component iterate on them , call callbacks on actions.

how should solve this? or should not use jsx different class definition? idea use jsx components derives fact they're extremely comfortable use, instantiation short , keeps instantiating classes code clean.

last not least: how can achieve this? not sure how implement such pattern, calling methods callback on jsx components not publicly available.

thanks help!


Comments