docs: Update components/table/demo/custom-filter-panel.md (#25502)

Improved the quality of the sample code.  Considered the case when the data does not exist. If the user searches, an error will be reported.
This commit is contained in:
yeshan333 2020-07-08 18:10:15 +08:00 committed by GitHub
parent ef02b382b7
commit 1a692de9e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,7 +82,7 @@ class App extends React.Component {
),
filterIcon: filtered => <SearchOutlined style={{ color: filtered ? '#1890ff' : undefined }} />,
onFilter: (value, record) =>
record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()),
record[dataIndex] ? record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()) : '',
onFilterDropdownVisibleChange: visible => {
if (visible) {
setTimeout(() => this.searchInput.select());
@ -94,7 +94,7 @@ class App extends React.Component {
highlightStyle={{ backgroundColor: '#ffc069', padding: 0 }}
searchWords={[this.state.searchText]}
autoEscape
textToHighlight={text.toString()}
textToHighlight={text ? text.toString() : ''}
/>
) : (
text