useLoader
is an Isomorphic API, usually used to make asynchronous requests. During Server-Side Rendering (SSR), the server uses useLoader
to prefetch the data, which is then reused on the client side.
The useLoader
API is currently not supported when using Rspack as the bundler.
runtimeContext
can refer to useRuntimeContext.
loaderFn
: function for loading data, returning a Promise.options
: optional configuration.
onSuccess
: successful callback.onError
: error callback.initialData
: the initial data before the first execution,.skip
: when the value is true
, the function does not execute.params
: when the result of the params
serialization changes, the function is re-executed. params
is also passed in as the second argument of the function.static
: when the value is true
, useLoader
is used for SSG.data
: return data on successful execution.loading
: indicates whether the function is in execution.error
: error message when function execution fails.reload
: the function can be re-executed after the call.
params
: when the value is undefined
, the last value will be reused; otherwise, the function will be re-executed with the new value.reloading
: during the execution of the call to reload
, the value of reloading
is true
.