Jim Meyer
Jim Meyer

Reputation: 53

How to use Relay in combination with complex local state in client-side store

According to https://stackoverflow.com/a/34958818/3589182 Relay should work fine when combined with complex local state in client-side store.

I'm having trouble finding an appropriate pattern to integrate the two.

It seems like the main way to handle interactions with Relay is this.props.relay.setVariables, but that puts the client state inside the Relay container.

If I maintain the state in a client store, I still need to notify the relevant Relay containers that their variables have changed.

Are there any recommended patterns to integrate Relay container variables with state changes in a client-side store?

Update: The best example of the kind of pattern I'm looking for so far is https://gist.github.com/fdecampredon/f337605e393a5b032b85#file-redux-relay-js-L73

A generic way to ensure that Relay variables are in sync with shared client-side state.

Maybe someone on the Relay team can outline how Facebook solved this at scale? :)

Upvotes: 2

Views: 960

Answers (1)

sboutzen
sboutzen

Reputation: 269

Pass a variable as a prop from your state component, and use this.props.relay.setVariables(someVariable: this.props.somePropFromStateComponent)

Upvotes: 0

Related Questions