hooks
hooks copied to clipboard
【RFC】useRequest support Suspense Mode
API
export type BaseOptions<R, P extends any[]> = {
// ...
// Enable React Suspense mode, default false.
suspense?: boolean;
// ...
};
// ...
function useRequest<R, P extends any[]>(
service: Service<P>,
options?: BaseOptions<R, P>,
): BaseResult<R, P>;
Suspense do not support SSR mode.
DEMO
import React, { Suspense } from 'react';
import { useRequest } from 'ahooks';
function Profile() {
const { data } = useRequest(service, { suspense: true });
return <div>hello, {data.name}</div>;
}
function App() {
return (
<Suspense fallback={<div>loading...</div>}>
<Profile />
</Suspense>
);
}
Implement
TODO
What's the status of this task?
What's the status of this task?
The current version does not support suspense, we will support it later when Suspense is stable.
What's the status of this task?
The current version does not support suspense, we will support it later when Suspense is stable.
I hope it's the time to support it as react 18 already out.
What's the status of this task?
The current version does not support suspense, we will support it later when Suspense is stable.
I hope it's the time to support it as react 18 already out.
I will work for it.