Sibelius Seraphini
Sibelius Seraphini

Reputation: 5633

Redux connect with Relay

How can I use redux connect with Relay.createContainer?

should I wrapper Relay.createContainer with redux or the other way?

or should I get redux state from context? what is the best approach?

if I get data from context how can I make the component rerender when redux state change?

My component needs to get data from redux and from relay

Upvotes: 1

Views: 513

Answers (1)

azium
azium

Reputation: 20634

As far as I'm concerned, Relay + Redux are a great fit together--there is app level state that has nothing to do with server state, data, or caching... stuff like, "is a global modal active?". It took quite a bit of soul searching and experimenting to come to this conclusion.

What I believe works the best is to treat React + Redux as if it were the default way to build your application, then wrap Relay on top of that.

Relay.createContainer(
  connect(mapStateToProps)(BaseComponent), 
  {
    initialVariables: { ... },
    fragments: { ... },
  }
)

Upvotes: 4

Related Questions