-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entry points docs #1
Comments
Entry points roadmap
|
I will point out hire also ref to Tests EntryPointContainer: useEntryPointLoader |
Is there any update on how to proceed from here ? |
There are some docs here: https://relay.dev/docs/api-reference/use-entrypoint-loader/ |
The docs at https://relay.dev/docs/api-reference/use-entrypoint-loader/ are clearly not complete enough to start using it. A concrete example would be more than welcome. |
It would be good to understand what issue(s) this is meant to solve. Im already heavily invested into relay hooks and it's really not apparent how and when to apply this given I can already render-as-I-fetch... |
There’s a YouTube video from the react team on entrypoints that explains it very well. Around the 19 mins mark |
Thanks... to me it looks like loadQuery() + loadingCode, in my use case in ReactNative the code is all local so perhaps this is not a useful.... I will study it further. |
How to use it with react navigation in React native plz?😊 |
Any movement on this in the past 3 years? |
Entry points
entry points is a pattern in Relay that enables the render-as-you-fetch pattern to be used in a simple way. In practice, it encapsulates a react component and its data requirements (queries) together in a way that allows for parallel data fetching.
Using entry points
The entry point
The entry point is responsible for defining what component and what queries to load.
In order to define an entry point, we would need two things, the
JSResourceReference
instance, and thegetPreloadProps
method. Further, in order to use the entry point, we will need aPreloadedEntryPoint
and theEntryPointContainer
React component.EntryPointComponent
The
EntryPointComponent
is the component that you define and that theEntryPointContainer
component will render once it's loaded.The props you specify on your
EntryPointComponent
will dictate what props you need to define in yourgetPreloadProps
method.JSResourceReference
Conceptually the JSResourceReference is a way to dynamically fetch a module (like dynamic import), but after it's been imported it will be available synchronously. This is needed for Suspense to work properly, as we will suspend while loading the component, but as soon as it's been loaded once we want to get it synchronously in order to render it.
Within an EntryPoint, this JSResourceReference must return a React component that matches the
EntryPointComponent
type that Relay provides.The JSResourceReference type signature is this
getPreloadProps
The
getPreloadProps
method is responsible for providing the query id/text and its variables for the queries the component requires. In more advanced use cases it also allows you to define further nested entry points that you want to be preloaded when the parent entry point is loading.EntryPoint
The entry point combines the
JSResourceReference
and thegetPreloadProps
method into an object that can be passed toloadEntryPoint
anduseEntryPointLoader
.The container
EntryPointContainer is the React component responsible for rendering the EntryPointComponent. It will suspend if the component is still loading.
It will take an entry point reference and pass the data returned from the
getPreloadProps
method as props to theEntryPointComponent
defined in theroot
field of the entry point.The reference
The
PreloadedEntryPoint
is what you will be passing to theEntryPointContainer
component. The PreloadedEntryPoint is a reference to an object holding the in-flight or fetched queries and components. It's the result of loading an entry point.There are two ways of acquiring a preloaded entry point, through
loadEntryPoint
anduseEntryPointLoader
.You will probably use the
useEntryPointLoader
hook more often in your code asloadEntryPoint
is more suited to be used outside of React, in a router for example. However, it's still useful in case you want to start preloading an entry point before rendering it.loadEntryPoint
You would want to use this if you are preloading entry points or wanting to use entry points outside of React.
useEntryPointLoader
useEntryPointLoader provides a React tailored API that can be useful if you want to use entry points within React. For example, tooltips and modals can make use of this.
The text was updated successfully, but these errors were encountered: