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

Add FinalFormAsyncSelect, AsyncSelectField, and FinalFormAsyncAutocomplete components #2069

Merged
merged 4 commits into from
Jun 5, 2024

Conversation

johnnyomair
Copy link
Collaborator

@johnnyomair johnnyomair commented May 15, 2024

Thin wrappers to ease using useAsyncOptionsProps() with FinalFormSelect and FinalFormAutocomplete.

Example

Previously:

const asyncOptionsProps = useAsyncOptionsProps(async () => {
    // Load options here
});

// ...

<Field component={FinalFormAsyncAutocomplete} {...asyncOptionsProps} />;

Now:

<Field
    component={FinalFormAsyncAutocomplete}
    loadOptions={async () => {
        // Load options here
    }}
/>

COM-793

Thin wrappers to ease using `useAsyncOptionsProps()` with `FinalFormSelect` and `FinalFormAutocomplete`.

**Example**

Previously:

```tsx
const asyncOptionsProps = useAsyncOptionsProps(async () => {
    // Load options here
});

// ...

<Field component={FinalFormAsyncAutocomplete} {...asyncOptionsProps} />;
```

Now:

```tsx
<Field
    component={FinalFormAsyncAutocomplete}
    loadOptions={async () => {
        // Load options here
    }}
/>
```
@johnnyomair johnnyomair self-assigned this May 15, 2024
@nsams
Copy link
Member

nsams commented May 15, 2024

@jamesricky do you also want a AsyncSelectField? And there is no AutocompleteField?!

@jamesricky
Copy link
Contributor

@jamesricky do you also want a AsyncSelectField? And there is no AutocompleteField?!

If that reduces the code that has to be written when building a form: yes

@johnnyomair
Copy link
Collaborator Author

@jamesricky do you also want a AsyncSelectField? And there is no AutocompleteField?!

What do you think about conditionally rendering the component in SelectField based on the props?

@johnnyomair johnnyomair requested review from jamesricky and removed request for thomasdax98 May 16, 2024 06:31
@jamesricky
Copy link
Contributor

@jamesricky do you also want a AsyncSelectField? And there is no AutocompleteField?!

What do you think about conditionally rendering the component in SelectField based on the props?

That would be cool 👍🏼

@johnnyomair
Copy link
Collaborator Author

@jamesricky do you also want a AsyncSelectField? And there is no AutocompleteField?!

What do you think about conditionally rendering the component in SelectField based on the props?

That would be cool 👍🏼

I tried this, but it doesn't make sense IMO. AsyncSelectField shouldn't support children etc. which SelectField supports. Having two separate components is probably better.

@johnnyomair johnnyomair requested a review from nsams June 4, 2024 14:18
@johnnyomair johnnyomair changed the title Add FinalFormAsyncSelect and FinalFormAsyncAutocomplete components Add FinalFormAsyncSelect, AsyncSelectField, and FinalFormAsyncAutocomplete components Jun 4, 2024
@johnnyomair
Copy link
Collaborator Author

And there is no AutocompleteField?!

Done in #2141.

@johnnyomair johnnyomair merged commit 16ffa7b into main Jun 5, 2024
11 checks passed
@johnnyomair johnnyomair deleted the final-form-async-components branch June 5, 2024 08:17
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.

None yet

3 participants