hooks icon indicating copy to clipboard operation
hooks copied to clipboard

【RFC】useRequest support Suspense Mode

Open jeasonstudio opened this issue 4 years ago • 4 comments

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

jeasonstudio avatar Jul 02 '20 03:07 jeasonstudio

What's the status of this task?

SunStupic avatar Mar 14 '22 04:03 SunStupic

What's the status of this task?

The current version does not support suspense, we will support it later when Suspense is stable.

brickspert avatar Mar 14 '22 11:03 brickspert

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.

devnomic avatar Apr 05 '22 04:04 devnomic

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.

brickspert avatar Apr 05 '22 06:04 brickspert