Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeScript] Make FormDataConsumer generic #8389

Conversation

Gabriel-Malenowitch
Copy link
Contributor

@Gabriel-Malenowitch Gabriel-Malenowitch commented Nov 13, 2022

What is it?

Contribution:

  • @viniciusbsneto thanks for your help and input during development during this pull request. I believe that we could both learn from each other in this task.

Code example:

const countries = ['bar', 'foo'] as const

interface FieldValues {
    country: typeof countries[number] | undefined
    city: string | undefined
}

const OrderEdit = (props) => (
    <Edit {...props}>
        <SimpleForm>
            <SelectInput source="country" choices={countries} />
            <FormDataConsumer<FieldValues>>
                {({ formData, ...rest }) =>
                     <SelectInput
                         source="city"
                         choices={getCitiesFor(formData.country)}
                         {...rest}
                     />
                }
            </FormDataConsumer>
        </SimpleForm>
    </Edit>
);

Typing screenshot suggestion example:

image

@Gabriel-Malenowitch Gabriel-Malenowitch force-pushed the enhancement/add-generic-types-in-form-data-consumer-input branch from c88b007 to 4baea0e Compare December 26, 2022 23:44
@vercel
Copy link

vercel bot commented Dec 26, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
react-admin-storybook 🔄 Building (Inspect) Dec 26, 2022 at 11:44PM (UTC)

@Gabriel-Malenowitch
Copy link
Contributor Author

Gabriel-Malenowitch commented Dec 27, 2022

@slax57 @lukascivil @viniciusbsneto About break lines, that was nice point. Thanks!
19b454c
Is missing broke someline? I checked here and that was all

@Gabriel-Malenowitch

This comment was marked as resolved.

@fzaninotto fzaninotto merged commit e63118c into marmelab:next Feb 10, 2023
@fzaninotto
Copy link
Member

Thanks!

@fzaninotto fzaninotto added this to the 4.8.0 milestone Feb 10, 2023
@fzaninotto fzaninotto changed the title [RFR] enhancement: add generic in form data consumer input [TypeScript] Make FormDataConsumer generic Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants