Skip to content

Commit

Permalink
Merge pull request #29449 from VickyStash/ts-migration/withNavigation…
Browse files Browse the repository at this point in the history
…Fallback-hoc

Remove 'withNavigationFallback.js' HOC
  • Loading branch information
techievivek authored Oct 17, 2023
2 parents 332ddc4 + bdf5836 commit 9390cf1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module.exports = {
},
{
selector: ['parameter', 'method'],
format: ['camelCase'],
format: ['camelCase', 'PascalCase'],
},
],
'@typescript-eslint/ban-types': [
Expand Down
7 changes: 1 addition & 6 deletions src/components/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import Icon from '../Icon';
import CONST from '../../CONST';
import * as StyleUtils from '../../styles/StyleUtils';
import HapticFeedback from '../../libs/HapticFeedback';
import withNavigationFallback from '../withNavigationFallback';
import compose from '../../libs/compose';
import * as Expensicons from '../Icon/Expensicons';
import withNavigationFocus from '../withNavigationFocus';
import validateSubmitShortcut from './validateSubmitShortcut';
Expand Down Expand Up @@ -328,10 +326,7 @@ class Button extends Component {
Button.propTypes = propTypes;
Button.defaultProps = defaultProps;

export default compose(
withNavigationFallback,
withNavigationFocus,
)(
export default withNavigationFocus(
React.forwardRef((props, ref) => (
<Button
// eslint-disable-next-line react/jsx-props-no-spreading
Expand Down
43 changes: 0 additions & 43 deletions src/components/withNavigationFallback.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/libs/getComponentDisplayName.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ComponentType} from 'react';

/** Returns the display name of a component */
export default function getComponentDisplayName(component: ComponentType): string {
export default function getComponentDisplayName<TProps>(component: ComponentType<TProps>): string {
return component.displayName ?? component.name ?? 'Component';
}
29 changes: 15 additions & 14 deletions src/stories/Composer.stories.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import React, {useState} from 'react';
import React, {useMemo, useState} from 'react';
import {View, Image} from 'react-native';
import {NavigationContext} from '@react-navigation/core';
import Composer from '../components/Composer';
import RenderHTML from '../components/RenderHTML';
import Text from '../components/Text';
import styles from '../styles/styles';
import themeColors from '../styles/themes/default';
import * as StyleUtils from '../styles/StyleUtils';
import CONST from '../CONST';
import withNavigationFallback from '../components/withNavigationFallback';

const ComposerWithNavigation = withNavigationFallback(Composer);

/**
* We use the Component Story Format for writing stories. Follow the docs here:
Expand All @@ -19,7 +17,7 @@ const ComposerWithNavigation = withNavigationFallback(Composer);
*/
const story = {
title: 'Components/Composer',
component: ComposerWithNavigation,
component: Composer,
};

const parser = new ExpensiMark();
Expand All @@ -28,19 +26,22 @@ function Default(args) {
const [pastedFile, setPastedFile] = useState(null);
const [comment, setComment] = useState(args.defaultValue);
const renderedHTML = parser.replace(comment);
const navigationContextValue = useMemo(() => ({addListener: () => () => {}, removeListener: () => () => {}}), []);

return (
<View>
<View style={[styles.border, styles.p4]}>
<ComposerWithNavigation
// eslint-disable-next-line react/jsx-props-no-spreading
{...args}
multiline
textAlignVertical="top"
onChangeText={setComment}
onPasteFile={setPastedFile}
style={[styles.textInputCompose, styles.w100]}
/>
<NavigationContext.Provider value={navigationContextValue}>
<Composer
// eslint-disable-next-line react/jsx-props-no-spreading
{...args}
multiline
textAlignVertical="top"
onChangeText={setComment}
onPasteFile={setPastedFile}
style={[styles.textInputCompose, styles.w100]}
/>
</NavigationContext.Provider>
</View>
<View style={[styles.flexRow, styles.mv5, styles.flexWrap, styles.w100]}>
<View
Expand Down

0 comments on commit 9390cf1

Please sign in to comment.