RelayEnvironmentProvider
RelayEnvironmentProvider
​
This component is used to set a Relay environment in React Context. Usually, a single instance of this component should be rendered at the very root of the application, in order to set the Relay environment for the whole application:
const React = require('React');
const {RelayEnvironmentProvider} = require('react-relay');
const Environment = createNewEnvironment();
function Root() {
return (
<RelayEnvironmentProvider environment={Environment}>
<App />
</RelayEnvironmentProvider>
);
}
module.exports = Root;
Props​
environment
: The Relay environment to set in React Context. Any Relay Hooks (likeuseLazyLoadQuery
oruseFragment
) used in descendants of this provider component will use the Relay environment specified here
Is this page useful?
Help us make the site even better by answering a few quick questions.