I have the following component hierarchy: A/B1/C1/D1 (B1 is child of A, C1 of B1 etc)
What are my options if I need to navigate from D1 to some another child B2 and back?
electrolobzik
01/30/2024, 7:36 PM
I can pass callback through all hierarchy to call B2 from D1, but it is a bit weird. The root back looks pretty strait-forward: I will pop B2 and it probably should bring B1/C1/D1 back. Are any other ways to do that?
a
Arkadii Ivanov
01/30/2024, 7:36 PM
You can pass a callback down the hierarchy, then call it from D1, and navigate in A.
e
electrolobzik
01/30/2024, 7:37 PM
Yes, I meant the same 🙂. But am not sure if it is the best option
a
Arkadii Ivanov
01/30/2024, 7:39 PM
Yeah, I've sent the message before I've seen your second one. 🙂 From my point of view, this is the best option. You can also share your root Config classes and then pass the root StackNavigator down the hierarchy. But it will result in coupling.