Skip to content

How to properly receive props data in react-select's custom component? #5340

Answered by hoffmanilya
stonix26 asked this question in Q&A
Discussion options

You must be logged in to vote

Check out the TypeScript documentation, specifically around adding custom props to the Select component.

You can access the props passed to the Select component using props.selectProps inside your Control component.

import React from "react";
import { components, ControlProps, GroupBase, Props } from "react-select";
import ReactSelectAsync, { AsyncProps } from "react-select/async";

// Add your custom props.
declare module "react-select/dist/declarations/src/Select" {
  export interface Props<
      Option,
      IsMulti extends boolean,
      Group extends GroupBase<Option>
  > {
      dynamicTitle: string
  }
}

type TCustomAsyncSelect = (
  props: Props &
    Pick<
      AsyncProps<unk…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@stonix26
Comment options

@SKaralius
Comment options

@Methuselah96
Comment options

@SKaralius
Comment options

Answer selected by stonix26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants