Reputation: 53
I started learn JS and have some problem in my feature. Goal of this feature - show 1 column of table and 1 column checkbox (for every row should be checkbox).
My code:
import React from 'react';
import { Table, Spin } from 'antd';
import PropTypes from 'prop-types';
import { useFetch } from 'innroad.common.ui';
import * as apiService from 'services/ApiService';
const AccountType = (onSelectingItems) => {
const [data, isLoading] = useFetch(apiService.getAccountType);
return (
<Spin spinning={isLoading}>
<Table
key="id"
bordered="true"
rowKey="id"
dataSource={data}
rowSelection={{ onChange: onSelectingItems }}
pagination={false}
>
<Table.Column title="Account Type" dataIndex="accountType" />
</Table>
</Spin>
);
};
AccountType.propTypes = {
onSelectingItems: PropTypes.func,
};
AccountType.defaultProps = {
onSelectingItems: () => { },
};
export default AccountType;
In this line I get error("'onSelectingItems' PropType is defined but prop is never used"). But I used this line in my code and I should use it. What is my mistake?
onSelectingItems: PropTypes.func,
Upvotes: 0
Views: 571
Reputation: 389
You need to destructure onSelectingItems
from the props.
Try change your code here:
const AccountType = ({ onSelectingItems }) => {
//code
};
Upvotes: 5