How to send data from fragment to deep nested component?
Asked Answered
N

0

8

I'm working with Relay Modern on Project. But I'm not sure how to send data from a place when I put fragment to place where Is component placed.

for example:

this is components composition

-Page (QueryRenderer)
---Header
---body
  ---List
     --UserAutocomplete

List is Fragment, something like fragment PaymentsList on Payment UserAutocomplete is also fragment but on RootQuery fragment UserAutocomplete_users on RootQuery

Actually, I put bout this fragment in query for QueryRenderer graphql` query PaymentQuery { ...PaymentsList ...UserAutocompleteFragment_users }

But then I got data for UserAutocomplete here and I must send this data for UserAtocomplete component down through props. Is there some better way something like got this data from a store instead of sending them through props?

Nickolas answered 11/11, 2017 at 10:58 Comment(4)
I have the same problem! I really want to be able to easily pass data through a component that is grouping a bunch of other components. The data isn't nested, it's flat. Not sure the best way to pass data through a parent componentStoma
I wonder why they didn't took Redux's connect example. The container should be something similar so instead of passing data down through props you get them directly from containersTarahtaran
First thing you get taught when learning Relay its that you should be able to work inside a component without need to know whats going on other containers, isn't Relay clever enough to pass you the properties from the top container to the bottom one directly?Cerography
Maybe there is an undocumented mechanism. Anyway, I wrote a proposal in github.com/facebook/relay/issues/2305, which at the end addresses this questionTarahtaran

© 2022 - 2024 — McMap. All rights reserved.