Uncaught Error: Objects are not valid as a React child (found: Error: Request failed with status code 400)
Всем привет. Я создаю страничку на React и у меня вылетает эта ошибка. Как я понимаю тут проблема в работе с массивами. Однако данный код нормально работал, до изменения API, сейчас я получаю ошибку. Может кто-то подсказать где я ошибаюсь?
code:
import React, { useState } from 'react';
import { Spin, Select, Button, Form, notification, Checkbox, Typography } from 'antd';
import PropTypes from 'prop-types';
import { useFetch, usePromise } from 'innroad.common.ui';
import * as apiService from 'services/ApiService';
import AccountTypesV2 from 'components/AccountTypesV2';
import AccountsV2 from 'components/AccountsV2';
import { LAYOUT, TAIL_LAYOUT } from 'constants/layouts';
import { useQueryParams } from 'hooks/useQueryParams';
import styles from './MovePropertyV2.scss';
const MovePropertyV2 = () => {
const onFail = (error) => notification.error({ message: error });
const onSuccess = (response) => {
if (response[0].includes('Exception')) {
notification.error({ message: response });
} else {
notification.success({ message: response });
}
};
const [{ isLoading: IsMoveProperty }, moveProperty] = usePromise(apiService.moveProperty, { onFail, onSuccess });
const [clients, isClientLoading] = useFetch(apiService.getAllActiveClents);
const [selectedAccountTypes, setSelectedItems] = useState([]);
// const handleFormFinish = (formValue) => console.log(formValue);
/* const [{ data: accounts, isLoading }, fetchAccounts, clientsId] = usePromise(
apiService.getAccountsByAccountTypes, { onFail, onSuccess }
); */
const [{ data: accounts, isLoading }, fetchAccounts] = usePromise(
apiService.getAccountsByAccountTypes, { onFail, onSuccess }
);
const [selectedAccountsToMove] = useState([]);
const { clientID, propertyID } = useQueryParams();
const [destinationClient] = useState();
const [existingSources, setExistingSources] = useState(false);
const [existingMerchantAccounts, setExistingMerchantAccounts] = useState(false);
const handleMoveAccount = () => {
const request = {
sourceClientId: clientID,
propertyID,
destinationClientId: destinationClient,
useExistingSources: existingSources,
useExistingMerchantAccounts: existingMerchantAccounts,
accountIds: selectedAccountsToMove,
};
moveProperty(request);
};
/* const accountSearch = () => {
clientsId();
fetchAccounts(selectedAccountTypes);
}; */
const [clientId] = useQueryParams();
const accountSearch = () => {
const requestData = {
clientId,
selectedAccountTypes,
};
fetchAccounts(requestData);
};
return (
<Spin spinning={isLoading}>
<Typography.Title>Move Property</Typography.Title>
<Form {...LAYOUT} onFinish={IsMoveProperty}>
<Form.Item {...TAIL_LAYOUT}>
<Select
placeholder="Destination Client Name"
loading={isClientLoading}
>
{clients.map((client) => (
<Select.Option key={client.id} value={client.id}>
{client.name}
</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item {...TAIL_LAYOUT}>
<Checkbox onChange={setExistingSources}>Use existing Source</Checkbox>
</Form.Item>
<Form.Item {...TAIL_LAYOUT}>
<Checkbox onChange={setExistingMerchantAccounts}>Use existing merchant accounts</Checkbox>
</Form.Item>
<Form.Item {...TAIL_LAYOUT}>
<AccountTypesV2 onSelectingItems={setSelectedItems} />
</Form.Item>
<Form.Item {...TAIL_LAYOUT}>
<Button htmlType="submit" onClick={accountSearch} className={styles.submitButton}>Search Account</Button>
</Form.Item>
<Form.Item {...TAIL_LAYOUT}>
{accounts
&& <AccountsV2 accounts={accounts} onSelectingItems={setSelectedItems} />}
</Form.Item>
<Form.Item {...TAIL_LAYOUT}>
<Button htmlType="submit" onClick={handleMoveAccount} className={styles.submitButton}>Move Property</Button>
</Form.Item>
</Form>
</Spin>
);
};
MovePropertyV2.propTypes = {
accountId: PropTypes.arrayOf(PropTypes.shape({})),
onSelectingItems: PropTypes.func,
};
MovePropertyV2.defaultProps = {
accountId: [],
onSelectingItems: () => { },
};
export default MovePropertyV2;
Component Accounts:
import React from 'react';
import { Table } from 'antd';
import PropTypes from 'prop-types';
const AccountsV2 = ({ accounts, onSelectingItems }) => (
<Table
key="id"
bordered="true"
rowKey="id"
dataSource={accounts}
rowSelection={{ onChange: onSelectingItems }}
pagination={false}
>
<Table.Column title="Account Type" dataIndex="accountTypeName" />
<Table.Column title="Account Number" dataIndex="accountNumber" />
<Table.Column title="Account Name" dataIndex="name" />
</Table>
);
AccountsV2.propTypes = {
accounts: PropTypes.arrayOf(PropTypes.shape({})),
onSelectingItems: PropTypes.func,
};
AccountsV2.defaultProps = {
accounts: [],
onSelectingItems: () => { },
};
export default AccountsV2;
Как я понимаю проблема в этом куске
<Form.Item {...TAIL_LAYOUT}>
<Button htmlType="submit" onClick={accountSearch} className={styles.submitButton}>Search Account</Button>
</Form.Item>
Проблема возникает когда я нажимаю на кнопку search account
Uncaught Error: Objects are not valid as a React child (found: Error: Request failed with status code 400). If you meant to render a collection of children, use an array instead.
Screen:

Смысл страницы в том что есть первая таблица, там пользователь выбирает какие-то пункты и на основе этого выпадает вторая таблица. Помимо этого, как вы видите на скриншоте там есть 400 ошибка. Однако API работает абсолютно правильно