forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#29531 from JKobrynski/migrateWithNavigat…
…ionToTypeScript [No QA] [TS Migration] migrate withNavigation.js to TypeScript
- Loading branch information
Showing
5 changed files
with
39 additions
and
46 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, {ComponentType, ForwardedRef, RefAttributes} from 'react'; | ||
import {NavigationProp, useNavigation} from '@react-navigation/native'; | ||
import getComponentDisplayName from '../libs/getComponentDisplayName'; | ||
|
||
type WithNavigationProps = { | ||
navigation: NavigationProp<ReactNavigation.RootParamList>; | ||
}; | ||
|
||
export default function withNavigation<TProps extends WithNavigationProps, TRef>( | ||
WrappedComponent: ComponentType<TProps & RefAttributes<TRef>>, | ||
): (props: Omit<TProps, keyof WithNavigationProps>, ref: ForwardedRef<TRef>) => React.JSX.Element | null { | ||
function WithNavigation(props: Omit<TProps, keyof WithNavigationProps>, ref: ForwardedRef<TRef>) { | ||
const navigation = useNavigation(); | ||
return ( | ||
<WrappedComponent | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...(props as TProps)} | ||
ref={ref} | ||
navigation={navigation} | ||
/> | ||
); | ||
} | ||
|
||
WithNavigation.displayName = `withNavigation(${getComponentDisplayName(WrappedComponent)})`; | ||
return React.forwardRef(WithNavigation); | ||
} |
7 changes: 5 additions & 2 deletions
7
src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters