-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 #9872 from Expensify/marcaaron-remove-react-naviga…
…tion-compat Remove `react-navigation` compat library
- Loading branch information
Showing
10 changed files
with
96 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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,41 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {useNavigation} from '@react-navigation/native'; | ||
import getComponentDisplayName from '../libs/getComponentDisplayName'; | ||
|
||
const withNavigationPropTypes = { | ||
navigation: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default function withNavigation(WrappedComponent) { | ||
const WithNavigation = (props) => { | ||
const navigation = useNavigation(); | ||
return ( | ||
<WrappedComponent | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
ref={props.forwardedRef} | ||
navigation={navigation} | ||
/> | ||
); | ||
}; | ||
|
||
WithNavigation.displayName = `withNavigation(${getComponentDisplayName(WrappedComponent)})`; | ||
WithNavigation.propTypes = { | ||
forwardedRef: PropTypes.oneOfType([ | ||
PropTypes.func, | ||
PropTypes.shape({current: PropTypes.instanceOf(React.Component)}), | ||
]), | ||
}; | ||
WithNavigation.defaultProps = { | ||
forwardedRef: undefined, | ||
}; | ||
return React.forwardRef((props, ref) => ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<WithNavigation {...props} forwardedRef={ref} /> | ||
)); | ||
} | ||
|
||
export { | ||
withNavigationPropTypes, | ||
}; |
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,41 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {useIsFocused} from '@react-navigation/native'; | ||
import getComponentDisplayName from '../libs/getComponentDisplayName'; | ||
|
||
const withNavigationFocusPropTypes = { | ||
isFocused: PropTypes.bool.isRequired, | ||
}; | ||
|
||
export default function withNavigationFocus(WrappedComponent) { | ||
const WithNavigationFocus = (props) => { | ||
const isFocused = useIsFocused(); | ||
return ( | ||
<WrappedComponent | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
ref={props.forwardedRef} | ||
isFocused={isFocused} | ||
/> | ||
); | ||
}; | ||
|
||
WithNavigationFocus.displayName = `withNavigationFocus(${getComponentDisplayName(WrappedComponent)})`; | ||
WithNavigationFocus.propTypes = { | ||
forwardedRef: PropTypes.oneOfType([ | ||
PropTypes.func, | ||
PropTypes.shape({current: PropTypes.instanceOf(React.Component)}), | ||
]), | ||
}; | ||
WithNavigationFocus.defaultProps = { | ||
forwardedRef: undefined, | ||
}; | ||
return React.forwardRef((props, ref) => ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<WithNavigationFocus {...props} forwardedRef={ref} /> | ||
)); | ||
} | ||
|
||
export { | ||
withNavigationFocusPropTypes, | ||
}; |
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