Skip to content

use with formik #111

Dec 24, 2021 · 5 comments · 3 replies
Discussion options

You must be logged in to vote

Here is a working Typescript example we use (getting some data for the dropdown via an async API call):

import { FormControl, FormLabel, FormHelperText, Box } from '@chakra-ui/react';
import { FieldProps } from 'formik';
import { Select } from "chakra-react-select";
import { AccountList, AccountOut } from '@/types';
import { getData} from '@/api';

interface Option{
    value: string
    label: string;
}

type OptionList= Array<Option>;

export const AsyncSelect = ({
    field,
    form: { setFieldValue },
    ...props
}: FieldProps) => {

    const { data, isLoading, error } = getData();

    const defaultValue = (options: OptionList, value: string) => {
        return options ? options.f…

Replies: 5 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jimages
Comment options

Answer selected by csandman
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@THE-SIMPLE-MARK
Comment options

@THE-SIMPLE-MARK
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants
Converted from issue

This discussion was converted from issue #23 on May 05, 2022 19:37.