diff --git a/src/components/CheckboxWithLabel.js b/src/components/CheckboxWithLabel.js index 6ac3180e174c..8ee5c6712a6e 100644 --- a/src/components/CheckboxWithLabel.js +++ b/src/components/CheckboxWithLabel.js @@ -40,6 +40,9 @@ const propTypes = { /** Error text to display */ errorText: PropTypes.string, + /** Value for checkbox. This prop is intended to be set by Form.js only */ + value: PropTypes.bool, + /** The default value for the checkbox */ defaultValue: PropTypes.bool, @@ -47,9 +50,11 @@ const propTypes = { forwardedRef: PropTypes.func, /** The ID used to uniquely identify the input in a Form */ + /* eslint-disable-next-line react/no-unused-prop-types */ inputID: PropTypes.string, /** Saves a draft of the input value when used in a form */ + /* eslint-disable-next-line react/no-unused-prop-types */ shouldSaveDraft: PropTypes.bool, }; @@ -61,6 +66,7 @@ const defaultProps = { errorText: '', shouldSaveDraft: false, isChecked: false, + value: false, defaultValue: false, forwardedRef: () => {}, }; @@ -69,7 +75,7 @@ class CheckboxWithLabel extends React.Component { constructor(props) { super(props); - this.isChecked = props.defaultValue || props.isChecked; + this.isChecked = props.value || props.defaultValue || props.isChecked; this.LabelComponent = props.LabelComponent; this.defaultStyles = [styles.flexRow, styles.alignItemsCenter]; this.wrapperStyles = _.isArray(props.style) ? [...this.defaultStyles, ...props.style] : [...this.defaultStyles, props.style]; @@ -92,8 +98,6 @@ class CheckboxWithLabel extends React.Component { label={this.props.label} hasError={Boolean(this.props.errorText)} forwardedRef={this.props.forwardedRef} - inputID={this.props.inputID} - shouldSaveDraft={this.props.shouldSaveDraft} /> )} defaultValue={ReimbursementAccountUtils.getDefaultStateForField(this.props, 'acceptTerms', false)} - shouldSaveDraft /> diff --git a/src/pages/settings/Payments/AddDebitCardPage.js b/src/pages/settings/Payments/AddDebitCardPage.js index 2e100bb78ba5..c60e261ce9c8 100644 --- a/src/pages/settings/Payments/AddDebitCardPage.js +++ b/src/pages/settings/Payments/AddDebitCardPage.js @@ -191,7 +191,6 @@ class DebitCardPage extends Component { )} style={[styles.mt4]} - shouldSaveDraft />