<RecoilRelayEnvironment>
A component that registers a Relay Environment to be used by GraphQL selectors or atom effects referenced by its child components with matching EnvironmentKey
.
Props
environment
- The Relay Environment object to register.environmentKey
- TheEnvironmentKey
object to associate this environment with.
Example
const myEnvironmentKey = new EnvironmentKey('My Environment');
function MyApp() {
return (
<RecoilRoot>
<RecoilRelayEnvironment
environment={myEnvironemnt}
environmentKey={myEnvironmentKey}>
{/** My App **/}
</RecoilRelayEnvironment>
</RecoilRoot>
)
}
const myQuery = graphQLSelector({
key: 'MyQuery',
environment: myEnvironmentKey,
query: graphql`...`,
variables: {},
});
function MyComponent() {
const results = useRecoilValue(myQuery);
}