RadioButton.Group does not support `0` as a value

Current behaviour

Cannot select a RadioButton inside of a RadioButton.Group whose value is 0

Expected behaviour

Should be able to select the value

Code sample

Try clicking the “First” and “Second” radio buttons. Notice that you cannot get “First” to become selected. This code is the example code from the docs, with the difference being that the value for the First button is {0} instead of {"0"}

Your Environment

software version
react-native 0.63.3
react-native-paper 4.3.0
node 14.13.1
npm 6.14.8
yarn 1.22.10
expo 39.0.2

See Snack link in the Code Sample section above

Author: Fantashit

1 thought on “RadioButton.Group does not support `0` as a value

  1. Add to that use case: internationalization. If you want to display different labels based on l10n/i18n, then you likely want to generalize the values of your selections.

    This is essentially why my codebase is using the array index (0 .. n) of the data being selected. We then look up the selection’s value in an internationalized label table to fetch the appropriate display value. We store the index value (0..n) in the database as the “data” for the selection.

Comments are closed.