diff --git a/src/components/Checkbox/BaseCheckbox.js b/src/components/Checkbox.js
similarity index 77%
rename from src/components/Checkbox/BaseCheckbox.js
rename to src/components/Checkbox.js
index c2310f4e7c36e..d4f6adbf2c6c6 100644
--- a/src/components/Checkbox/BaseCheckbox.js
+++ b/src/components/Checkbox.js
@@ -1,23 +1,19 @@
import React from 'react';
import {View, Pressable} from 'react-native';
import PropTypes from 'prop-types';
-import styles from '../../styles/styles';
-import themeColors from '../../styles/themes/default';
-import stylePropTypes from '../../styles/stylePropTypes';
-import Icon from '../Icon';
-import * as Expensicons from '../Icon/Expensicons';
-
-// eslint-disable-next-line rulesdir/prefer-early-return
-const requiredPropsCheck = (props, componentName) => {
- if (!props.onMouseDown && !props.onPress) {
- return new Error(`One of "onMouseDown" or "onPress" must be provided in ${componentName}`);
- }
-};
+import styles from '../styles/styles';
+import themeColors from '../styles/themes/default';
+import stylePropTypes from '../styles/stylePropTypes';
+import Icon from './Icon';
+import * as Expensicons from './Icon/Expensicons';
const propTypes = {
/** Whether checkbox is checked */
isChecked: PropTypes.bool,
+ /** A function that is called when the box/label is pressed */
+ onPress: PropTypes.func.isRequired,
+
/** Should the input be styled for errors */
hasError: PropTypes.bool,
@@ -30,17 +26,14 @@ const propTypes = {
/** Additional styles to add to checkbox button */
style: stylePropTypes,
+ /** Callback that is called when mousedown is triggered. */
+ onMouseDown: PropTypes.func,
+
/** A ref to forward to the Pressable */
forwardedRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({current: PropTypes.instanceOf(React.Component)}),
]),
-
- /** A function that is called when the box/label is pressed */
- onPress: requiredPropsCheck,
-
- /** Callback that is called when mousedown is triggered. */
- onMouseDown: requiredPropsCheck,
};
const defaultProps = {
@@ -51,10 +44,9 @@ const defaultProps = {
forwardedRef: undefined,
children: null,
onMouseDown: undefined,
- onPress: undefined,
};
-class BaseCheckbox extends React.Component {
+class Checkbox extends React.Component {
constructor(props) {
super(props);
this.state = {
@@ -80,11 +72,7 @@ class BaseCheckbox extends React.Component {
return;
}
- if (this.props.onPress) {
- this.props.onPress(event);
- } else {
- this.props.onMouseDown(event);
- }
+ this.props.onPress();
}
firePressHandlerOnClick(event) {
@@ -94,9 +82,7 @@ class BaseCheckbox extends React.Component {
return;
}
- if (this.props.onPress) {
- this.props.onPress(event);
- }
+ this.props.onPress();
}
render() {
@@ -135,7 +121,7 @@ class BaseCheckbox extends React.Component {
}
}
-BaseCheckbox.propTypes = propTypes;
-BaseCheckbox.defaultProps = defaultProps;
+Checkbox.propTypes = propTypes;
+Checkbox.defaultProps = defaultProps;
-export default BaseCheckbox;
+export default Checkbox;
diff --git a/src/components/Checkbox/index.js b/src/components/Checkbox/index.js
deleted file mode 100644
index 0fb56725b1427..0000000000000
--- a/src/components/Checkbox/index.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import React from 'react';
-import BaseCheckbox from './BaseCheckbox';
-
-const Checkbox = props => (
-
-);
-
-Checkbox.propTypes = BaseCheckbox.propTypes;
-Checkbox.defaultProps = BaseCheckbox.defaultProps;
-Checkbox.displayName = 'Checkbox';
-
-export default Checkbox;
diff --git a/src/components/Checkbox/index.native.js b/src/components/Checkbox/index.native.js
deleted file mode 100644
index 0fd4ee2716e6e..0000000000000
--- a/src/components/Checkbox/index.native.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import React from 'react';
-import BaseCheckbox from './BaseCheckbox';
-
-const Checkbox = props => (
-
-);
-
-Checkbox.propTypes = BaseCheckbox.propTypes;
-Checkbox.defaultProps = BaseCheckbox.defaultProps;
-Checkbox.displayName = 'Checkbox';
-
-export default Checkbox;
diff --git a/src/components/TextInput/BaseTextInput.js b/src/components/TextInput/BaseTextInput.js
index 46f7109aec9ea..fe29ff79bf254 100644
--- a/src/components/TextInput/BaseTextInput.js
+++ b/src/components/TextInput/BaseTextInput.js
@@ -186,11 +186,7 @@ class BaseTextInput extends Component {
]).start();
}
- togglePasswordVisibility(event) {
- if (!event) {
- return;
- }
- event.preventDefault();
+ togglePasswordVisibility() {
this.setState(prevState => ({passwordHidden: !prevState.passwordHidden}));
}
@@ -295,7 +291,8 @@ class BaseTextInput extends Component {
{this.props.secureTextEntry && (
e.preventDefault()}
>