Skip to content

How can I extend the props to include my own? #32

Answered by csandman
tuhin-tsm asked this question in Q&A
Discussion options

You must be logged in to vote

I modified your example to work right, you need to accept the generics into your component by defining them before your arguments of your component.

https://codesandbox.io/s/friendly-microservice-s9wug?file=/src/AutoComplete.tsx

import * as React from "react";
import { Box } from "@chakra-ui/react";
import {
  Props,
  Select as ChakraReactSelect,
  GroupBase, // Used for your generic's default value
  ChakraStylesConfig
} from "chakra-react-select";

interface ExtraProps {
  dataTestId?: string;
  // may be some other props
}

// Define your generics after the component's name in order to forward them to the underlying `Select`
export function AutoComplete<
  Option,
  IsMulti extends bo…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@tuhin-tsm
Comment options

@csandman
Comment options

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