Nested react components? #1499
-
Hello! What is the best way to deal with nested react components? Suppose component A is managed by a root machine A'. While A' is in some state S, I would like A to render a new component B and start a service B', managing B's state. I would also like B to listen for events and notify A' through B'. There are two ways I've been attacking this:
Which of these two would be better, or is there a third option? Any and all help is appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I watched an egghead.io lesson yesterday on splitting a component into 2 files. There are files on Github.
|
Beta Was this translation helpful? Give feedback.
-
To make this work you could pass the parent service to the inner component (as a prop or whatever) and just use things like
You can grab the child from |
Beta Was this translation helpful? Give feedback.
To make this work you could pass the parent service to the inner component (as a prop or whatever) and just use things like
send(event, { to: parent })
. Don't treat this situation as a parent-child situation but rather just 2 separate machines that happen to know each other "addresses" (well, to get "child"'s address in the "parent" you would have to greet it with an event in this situation).