小编Fel*_*iro的帖子

创建自定义组件时如何使用 react-select 类型?

我正在尝试为 DropdownIndicator 创建自定义组件并在使用 Typescript 的 react-select 上使用,但是我在组件类型方面遇到了一些问题,因为我是 typescript 的新手。

如何在我的组件上使用在 @types/react-select 上定义的类型?

我已经安装了 @types/react-select 并且已经有一个DropdownIndicator 类型,但我找不到引用它的方法。

这是我的index.tsx

import React from 'react';
import Select from 'react-select';

import DropdownIndicator from './dropdown-indicator';

const components = {
  DropdownIndicator,
};

const SelectFilter: React.FC = () => {
  return <Select components={components} />;
};

export default React.memo(SelectFilter);
Run Code Online (Sandbox Code Playgroud)

这是我的dropdown-indicator.tsx

import React from 'react';

import DropdownIcon from './dropdown-icon';

const DropdownIndicator: React.FC = props => {
  const {
    selectProps: { isMenuOpen },
  } = …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs react-select

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

如何在MongoDB查询中过滤和映射文档数组?

所以我在我的人物收藏中有这些文件:

{
        "_id" : ObjectId("595c0630939a8ae59053a9c3"),
        "name" : "John Smith",
        "age" : 37,
        "location" : "San Francisco, CA",
        "hobbies" : [
                {
                        "name" : "Cooking",
                        "type" : "Indoor",
                        "regular" : true
                },
                {
                        "name" : "Baseball",
                        "type" : "Outdoor",
                        "regular" : false
                }
        ]
}
{
        "_id" : ObjectId("595c06b7939a8ae59053a9c4"),
        "name" : "Miranda Thompson",
        "age" : 26,
        "location" : "Modesto, CA",
        "hobbies" : [
                {
                        "name" : "Lego building",
                        "type" : "Indoor",
                        "regular" : false
                },
                {
                        "name" : "Yoga",
                        "type" : …
Run Code Online (Sandbox Code Playgroud)

mongodb aggregation-framework

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