[英]How to access relay environment outside fragment container
I have a component wrapped in createFragmentContainer(), which I think is how this component got 'relay' attached to it as a prop. 我有一个包装在createFragmentContainer()中的组件,我认为这个组件如何将'relay'作为prop附加到它上面。 Then somewhere in this component we have:
然后在这个组件的某个地方我们有:
commitMutationAsync(this.props.relay.environment, {something, something});
Now I want to call commitMutationAsync somewhere else, is there a way to get this relay environment instance without wrapping HOC onto a component? 现在我想在其他地方调用commitMutationAsync,有没有办法获得这个中继环境实例而不将HOC包装到组件上?
I don't know the change between relay modern and relay. 我不知道继电器现代和继电器之间的变化。 Is Relay.Store a potential solution?
Relay.Store是一个潜在的解决方案吗?
import environment from 'src/environment'
(or whatever the environment's path is) import environment from 'src/environment'
(或者无论环境的路径是什么)
and don't forget to export it from the file 并且不要忘记从文件中导出它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.