diff --git a/packages/client/src/api-client/demos/demo3.tsx b/packages/client/src/api-client/demos/demo3.tsx index bf47a55f8..44070dcf5 100644 --- a/packages/client/src/api-client/demos/demo3.tsx +++ b/packages/client/src/api-client/demos/demo3.tsx @@ -1,5 +1,6 @@ +import { uid } from '@formily/shared'; import { APIClient, APIClientProvider, useAPIClient, useRequest } from '@nocobase/client'; -import { Button, Table } from 'antd'; +import { Button, Input, Space, Table } from 'antd'; import MockAdapter from 'axios-mock-adapter'; import React from 'react'; @@ -14,8 +15,8 @@ mock.onGet('/users:list').reply(async () => { 200, { data: [ - { id: 1, name: 'John Smith' }, - { id: 2, name: 'James' }, + { id: 1, name: uid() }, + { id: 2, name: uid() }, ], }, ]; @@ -46,14 +47,20 @@ const ComponentA = () => { const ComponentB = () => { console.log('ComponentB'); const apiClient = useAPIClient(); - return ; + return ( + + + + + ); }; export default () => { return ( -

+
+
); diff --git a/packages/client/src/api-client/hooks/useRequest.ts b/packages/client/src/api-client/hooks/useRequest.ts index 165eb01c2..445d53899 100644 --- a/packages/client/src/api-client/hooks/useRequest.ts +++ b/packages/client/src/api-client/hooks/useRequest.ts @@ -18,7 +18,7 @@ type ResourceActionOptions

= { export function useRequest

( service: AxiosRequestConfig

| ResourceActionOptions

| FunctionService, - options?: Options & { uid?: string }, + options: Options & { uid?: string } = {}, ) { const api = useContext(APIClientContext); if (typeof service === 'function') {