danish1658 / react-native-dropdown-select-list

☝️ React Native Select List Equivalent to Html's Select with options"
https://www.npmjs.com/package/react-native-dropdown-select-list
MIT License
193 stars 90 forks source link

Expose the value prop #113

Open TonySilva7 opened 5 months ago

TonySilva7 commented 5 months ago

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"
      />