From 145940fc6fb2a7e6143f8b12f00d0de7717917df Mon Sep 17 00:00:00 2001 From: chenos Date: Fri, 28 Jan 2022 12:17:22 +0800 Subject: [PATCH] fix(client): cannot read properties of undefined (reading 'onSuccess') --- packages/client/src/api-client/demos/demo3.tsx | 17 ++++++++++++----- .../client/src/api-client/hooks/useRequest.ts | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) 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') {