小编Sar*_*ena的帖子

Antd 选择搜索框不呈现匹配项

我有产品数据,我正在使用搜索值过滤数据,然后使用过滤后的数据呈现选项。产品数据来自全球 redux 商店作为道具。出于某种原因,下拉列表仅在搜索值为空时显示数据,当我开始输入时,filteredData更新并重新呈现组件,但选项不显示数据。

我已经检查了是否使用权限filteredData来映射选项。即使重新渲染组件,这些选项似乎也不会渲染。

请看下面的代码:

import React from 'react';
// import {useState} from 'react';
import {Select} from 'antd';
import {connect} from 'react-redux';
import {fetchProductsAsync} from 'common/actions/fetchData';

const {Option} = Select;

class SelectOptions extends React.Component {
  state = {
    filteredData: [],
    value: undefined,
  };

  componentDidMount() {
    const {fetchProductsAsync} = this.props;
    fetchProductsAsync();
    const {products} = this.props;
    this.setState({filteredData: products || []});
  }

  componentDidUpdate() {
    console.log(this.state.filteredData);
  }

  filterData = (value) => {
    const {products} = this.props;
    const filData = products.filter((prod) …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs antd react-select-search

1
推荐指数
1
解决办法
799
查看次数

标签 统计

antd ×1

javascript ×1

react-select-search ×1

reactjs ×1