useRelayEnvironment
useRelayEnvironment
​
Hook used to access a Relay environment that was set by a RelayEnvironmentProvider
:
const React = require('React');
const {useRelayEnvironment} = require('react-relay');
function MyComponent() {
const environment = useRelayEnvironment();
const handler = useCallback(() => {
// For example, can be used to pass the environment to functions
// that require a Relay environment.
commitMutation(environment, ...);
}, [environment])
return (...);
}
module.exports = MyComponent;
Is this page useful?
Help us make the site even better by answering a few quick questions.