Hook used to make it easy to safely work with EntryPoints, while avoiding data leaking into the Relay store. It will keep an EntryPoint reference in state, and dispose of it when it is no longer accessible via state.
environmentProvider: an object with a
getEnvironmentmethod that returns a relay environment.
EntryPoint: the EntryPoint, usually acquired by importing a
TEntryPointParams: the type of the first argument to the
getPreloadPropsmethod of the EntryPoint.
TPreloadedQueries: the type of the
queriesprop passed to the EntryPoint component.
TPreloadedEntryPoints: the type of the
entryPointsprop passed to the EntryPoint component.
TRuntimeProps: the type of the
propsprop passed to
EntryPointContainer. This object is passed down to the EntryPoint component, also as
TExtraProps: if an EntryPoint's
getPreloadPropsmethod returns an object with an
extraPropsproperty, those extra props will be passed to the EntryPoint component as
extraPropsand have type
TEntryPointComponent: the type of the EntryPoint component.
TEntryPoint: the type of the EntryPoint.
A tuple containing the following values:
entryPointReference: the EntryPoint reference, or
loadEntryPoint: a callback that, when executed, will load an EntryPoint, which will be accessible as
entryPointReference. If a previous EntryPoint was loaded, it will dispose of it. It may throw an error if called during React's render phase.
params: TEntryPointParams: the params passed to the EntryPoint's
disposeEntryPoint: a callback that, when executed, will set
.dispose()on it. It has type
() => void. It should not be called during React's render phase.
- When the
loadEntryPointcallback is called, each of an EntryPoint's associated queries (if it has any) will load their query data and query AST. Once both the query AST and the data are available, the data will be written to the store. This differs from the behavior of
prepareEntryPoint_DEPRECATED, which would only write the data from an associated query to the store when that query was rendered with
- The EntryPoint reference's associated query references will be retained by the Relay store, preventing it the data from being garbage collected. Once you call
.dispose()on the EntryPoint reference, the data from the associated queries is liable to be garbage collected.
loadEntryPointcallback may throw an error if it is called during React's render phase.
Is this page useful?