diff --git a/src/components/RadioButtons.js b/src/components/RadioButtons.tsx similarity index 57% rename from src/components/RadioButtons.js rename to src/components/RadioButtons.tsx index 455f4dad16743..cf9830d4b9677 100644 --- a/src/components/RadioButtons.js +++ b/src/components/RadioButtons.tsx @@ -1,36 +1,34 @@ import React, {useState} from 'react'; import {View} from 'react-native'; -import PropTypes from 'prop-types'; -import _ from 'underscore'; import RadioButtonWithLabel from './RadioButtonWithLabel'; import styles from '../styles/styles'; -const propTypes = { +type Choice = { + label: string; + value: string; +}; + +type RadioButtonsProps = { /** List of choices to display via radio buttons */ - items: PropTypes.arrayOf( - PropTypes.shape({ - label: PropTypes.string.isRequired, - value: PropTypes.string.isRequired, - }), - ).isRequired, + items: Choice[]; /** Callback to fire when selecting a radio button */ - onPress: PropTypes.func.isRequired, + onPress: (value: string) => void; }; -function RadioButtons(props) { +function RadioButtons({items, onPress}: RadioButtonsProps) { const [checkedValue, setCheckedValue] = useState(''); return ( - {_.map(props.items, (item, index) => ( + {items.map((item) => ( { setCheckedValue(item.value); - return props.onPress(item.value); + return onPress(item.value); }} label={item.label} /> @@ -39,7 +37,6 @@ function RadioButtons(props) { ); } -RadioButtons.propTypes = propTypes; RadioButtons.displayName = 'RadioButtons'; export default RadioButtons;