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

Expose the value prop #113

Open
TonySilva7 opened this issue Mar 19, 2024 · 0 comments
Open

Expose the value prop #113

TonySilva7 opened this issue Mar 19, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@TonySilva7
Copy link

TonySilva7 commented Mar 19, 2024

It would be interesting if you exposed the value prop to facilitate integration with the Controller from react-hook-form.

Instead of using it like this...

<Controller
        control={control}
        render={({field: {onChange, value}}) => (
          <SelectList
            setSelected={onChange}
            data={options}
            save="value"
            fontFamily={fonts.family.jostRegular}
            defaultOption={{
              key: value,
              value: options.find(o => o.value === value)?.label ?? value,
            }}
          />
        )}
        name="fruits"
      />

We would use it like this...

<Controller
        control={control}
        render={({field: {onChange, value}}) => (
          <SelectList
            setSelected={onChange}
            data={options}
            save="value"
            fontFamily={fonts.family.jostRegular}
            value={value} // here <<-----
          />
        )}
        name="fruits"
      />
@danish1658 danish1658 added the enhancement New feature or request label Mar 20, 2024
@danish1658 danish1658 self-assigned this Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants