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

不羁的心 提交于 2019-12-10 23:41:28

问题


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? :)


回答1:


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



来源:https://stackoverflow.com/questions/35723878/how-to-use-relay-in-combination-with-complex-local-state-in-client-side-store

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!