Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 11 additions & 9 deletions __mocks__/react-native-safe-area-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ const insets = {
};

function withSafeAreaInsets(WrappedComponent) {
const WithSafeAreaInsets = (props) => (
<WrappedComponent
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
// eslint-disable-next-line react/prop-types
ref={props.forwardedRef}
insets={insets}
/>
);
function WithSafeAreaInsets(props) {

@parasharrajat parasharrajat Jun 13, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we also changing the nested functions? Logically this is a component.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand ... the outer function withSafeAreaInsets is a plain function, and the inner on WithSafeAreaInsets is a functional component (because it returns a JSX element).

So the inner functional component should follow our functional component style.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the inner functions that returns JSX should also be using function keyboard.

@marcaaron marcaaron Jun 13, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of why we'd make an exception here. This change looks good to me.

return (
<WrappedComponent
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
// eslint-disable-next-line react/prop-types
ref={props.forwardedRef}
insets={insets}
/>
);
}
return forwardRef((props, ref) => (
<WithSafeAreaInsets
// eslint-disable-next-line react/jsx-props-no-spreading
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
"electron": "22.3.7",
"electron-builder": "24.4.0",
"eslint": "^7.6.0",
"eslint-config-expensify": "^2.0.36",
"eslint-config-expensify": "^2.0.38",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-jest": "^24.1.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
Expand Down
48 changes: 25 additions & 23 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,31 @@ LogBox.ignoreLogs([

const fill = {flex: 1};

const App = () => (
<GestureHandlerRootView style={fill}>
<ComposeProviders
components={[
OnyxProvider,
SafeAreaProvider,
PortalProvider,
SafeArea,
LocaleContextProvider,
HTMLEngineProvider,
WindowDimensionsProvider,
KeyboardStateProvider,
CurrentReportIdContextProvider,
PickerStateProvider,
]}
>
<CustomStatusBar />
<ErrorBoundary errorMessage="NewExpensify crash caught by error boundary">
<Expensify />
</ErrorBoundary>
</ComposeProviders>
</GestureHandlerRootView>
);
function App() {
return (
<GestureHandlerRootView style={fill}>
<ComposeProviders
components={[
OnyxProvider,
SafeAreaProvider,
PortalProvider,
SafeArea,
LocaleContextProvider,
HTMLEngineProvider,
WindowDimensionsProvider,
KeyboardStateProvider,
CurrentReportIdContextProvider,
PickerStateProvider,
]}
>
<CustomStatusBar />
<ErrorBoundary errorMessage="NewExpensify crash caught by error boundary">
<Expensify />
</ErrorBoundary>
</ComposeProviders>
</GestureHandlerRootView>
);
}

App.displayName = 'App';

Expand Down
70 changes: 36 additions & 34 deletions src/components/AddPaymentMethodMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,41 +43,43 @@ const defaultProps = {
betas: [],
};

const AddPaymentMethodMenu = (props) => (
<PopoverMenu
isVisible={props.isVisible}
onClose={props.onClose}
anchorPosition={props.anchorPosition}
onItemSelected={props.onClose}
menuItems={[
{
text: props.translate('common.bankAccount'),
icon: Expensicons.Bank,
onSelected: () => {
props.onItemSelected(CONST.PAYMENT_METHODS.BANK_ACCOUNT);
function AddPaymentMethodMenu(props) {
return (
<PopoverMenu
isVisible={props.isVisible}
onClose={props.onClose}
anchorPosition={props.anchorPosition}
onItemSelected={props.onClose}
menuItems={[
{
text: props.translate('common.bankAccount'),
icon: Expensicons.Bank,
onSelected: () => {
props.onItemSelected(CONST.PAYMENT_METHODS.BANK_ACCOUNT);
},
},
},
...(Permissions.canUseWallet(props.betas)
? [
{
text: props.translate('common.debitCard'),
icon: Expensicons.CreditCard,
onSelected: () => props.onItemSelected(CONST.PAYMENT_METHODS.DEBIT_CARD),
},
]
: []),
...(props.shouldShowPaypal && !props.payPalMeData.description
? [
{
text: props.translate('common.payPalMe'),
icon: Expensicons.PayPal,
onSelected: () => props.onItemSelected(CONST.PAYMENT_METHODS.PAYPAL),
},
]
: []),
]}
/>
);
...(Permissions.canUseWallet(props.betas)
? [
{
text: props.translate('common.debitCard'),
icon: Expensicons.CreditCard,
onSelected: () => props.onItemSelected(CONST.PAYMENT_METHODS.DEBIT_CARD),
},
]
: []),
...(props.shouldShowPaypal && !props.payPalMeData.description
? [
{
text: props.translate('common.payPalMe'),
icon: Expensicons.PayPal,
onSelected: () => props.onItemSelected(CONST.PAYMENT_METHODS.PAYPAL),
},
]
: []),
]}
/>
);
}

AddPaymentMethodMenu.propTypes = propTypes;
AddPaymentMethodMenu.defaultProps = defaultProps;
Expand Down
4 changes: 2 additions & 2 deletions src/components/AddressSearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const defaultProps = {
// Do not convert to class component! It's been tried before and presents more challenges than it's worth.
// Relevant thread: https://expensify.slack.com/archives/C03TQ48KC/p1634088400387400
// Reference: https://github.com/FaridSafi/react-native-google-places-autocomplete/issues/609#issuecomment-886133839
const AddressSearch = (props) => {
function AddressSearch(props) {
const [displayListViewBorder, setDisplayListViewBorder] = useState(false);
const containerRef = useRef();
const query = useMemo(
Expand Down Expand Up @@ -291,7 +291,7 @@ const AddressSearch = (props) => {
</View>
</ScrollView>
);
};
}

AddressSearch.propTypes = propTypes;
AddressSearch.defaultProps = defaultProps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const defaultProps = {
...anchorForAttachmentsOnlyDefaultProps,
};

const BaseAnchorForAttachmentsOnly = (props) => {
function BaseAnchorForAttachmentsOnly(props) {
const sourceURL = props.source;
const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL);
const sourceID = (sourceURL.match(CONST.REGEX.ATTACHMENT_ID) || [])[1];
Expand Down Expand Up @@ -70,7 +70,7 @@ const BaseAnchorForAttachmentsOnly = (props) => {
)}
</ShowContextMenuContext.Consumer>
);
};
}

BaseAnchorForAttachmentsOnly.displayName = 'BaseAnchorForAttachmentsOnly';
BaseAnchorForAttachmentsOnly.propTypes = propTypes;
Expand Down
18 changes: 10 additions & 8 deletions src/components/AnchorForAttachmentsOnly/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import BaseAnchorForAttachmentsOnly from './BaseAnchorForAttachmentsOnly';
import * as DeviceCapabilities from '../../libs/DeviceCapabilities';
import ControlSelection from '../../libs/ControlSelection';

const AnchorForAttachmentsOnly = (props) => (
<BaseAnchorForAttachmentsOnly
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
onPressIn={() => DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()}
onPressOut={() => ControlSelection.unblock()}
/>
);
function AnchorForAttachmentsOnly(props) {
return (
<BaseAnchorForAttachmentsOnly
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
onPressIn={() => DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()}
onPressOut={() => ControlSelection.unblock()}
/>
);
}

AnchorForAttachmentsOnly.propTypes = anchorForAttachmentsOnlyPropTypes.propTypes;
AnchorForAttachmentsOnly.defaultProps = anchorForAttachmentsOnlyPropTypes.defaultProps;
Expand Down
16 changes: 9 additions & 7 deletions src/components/AnchorForAttachmentsOnly/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import * as anchorForAttachmentsOnlyPropTypes from './anchorForAttachmentsOnlyPr
import BaseAnchorForAttachmentsOnly from './BaseAnchorForAttachmentsOnly';
import styles from '../../styles/styles';

const AnchorForAttachmentsOnly = (props) => (
<BaseAnchorForAttachmentsOnly
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
style={styles.mw100}
/>
);
function AnchorForAttachmentsOnly(props) {
return (
<BaseAnchorForAttachmentsOnly
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
style={styles.mw100}
/>
);
}

AnchorForAttachmentsOnly.propTypes = anchorForAttachmentsOnlyPropTypes.propTypes;
AnchorForAttachmentsOnly.defaultProps = anchorForAttachmentsOnlyPropTypes.defaultProps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const defaultProps = {
/*
* This is a default anchor component for regular links.
*/
const BaseAnchorForCommentsOnly = (props) => {
function BaseAnchorForCommentsOnly(props) {
let linkRef;
const rest = _.omit(props, _.keys(propTypes));
const linkProps = {};
Expand Down Expand Up @@ -85,7 +85,7 @@ const BaseAnchorForCommentsOnly = (props) => {
</Tooltip>
</PressableWithSecondaryInteraction>
);
};
}

BaseAnchorForCommentsOnly.propTypes = propTypes;
BaseAnchorForCommentsOnly.defaultProps = defaultProps;
Expand Down
22 changes: 12 additions & 10 deletions src/components/AnchorForCommentsOnly/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import * as DeviceCapabilities from '../../libs/DeviceCapabilities';
import ControlSelection from '../../libs/ControlSelection';
import styles from '../../styles/styles';

const AnchorForCommentsOnly = (props) => (
<View style={styles.dInline}>
<BaseAnchorForCommentsOnly
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
onPressIn={() => DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()}
onPressOut={() => ControlSelection.unblock()}
/>
</View>
);
function AnchorForCommentsOnly(props) {
return (
<View style={styles.dInline}>
<BaseAnchorForCommentsOnly
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
onPressIn={() => DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()}
onPressOut={() => ControlSelection.unblock()}
/>
</View>
);
}

AnchorForCommentsOnly.propTypes = anchorForCommentsOnlyPropTypes.propTypes;
AnchorForCommentsOnly.defaultProps = anchorForCommentsOnlyPropTypes.defaultProps;
Expand Down
4 changes: 2 additions & 2 deletions src/components/AnchorForCommentsOnly/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as anchorForCommentsOnlyPropTypes from './anchorForCommentsOnlyPropType
import BaseAnchorForCommentsOnly from './BaseAnchorForCommentsOnly';

// eslint-disable-next-line react/jsx-props-no-spreading
const AnchorForCommentsOnly = (props) => {
function AnchorForCommentsOnly(props) {
const onPress = () => (_.isFunction(props.onPress) ? props.onPress() : Linking.openURL(props.href));

return (
Expand All @@ -16,7 +16,7 @@ const AnchorForCommentsOnly = (props) => {
onPress={onPress}
/>
);
};
}

AnchorForCommentsOnly.propTypes = anchorForCommentsOnlyPropTypes.propTypes;
AnchorForCommentsOnly.defaultProps = anchorForCommentsOnlyPropTypes.defaultProps;
Expand Down
4 changes: 2 additions & 2 deletions src/components/AnimatedStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const defaultProps = {
style: [],
};

const AnimatedStep = (props) => {
function AnimatedStep(props) {
function getAnimationStyle(direction) {
let animationStyle;

Expand All @@ -43,7 +43,7 @@ const AnimatedStep = (props) => {
{props.children}
</Animatable.View>
);
};
}

AnimatedStep.propTypes = propTypes;
AnimatedStep.defaultProps = defaultProps;
Expand Down
Loading