Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @ts-ignore
<Component
ref={forwardedRef}
{...rest}
getParam={navigation.getParam}
navigateAppend={this._navigateAppend}
navigateUp={this._navigateUp}
/>
)
}
}
const WithForwardRef = React.forwardRef((props: WithSafeNavigationProps, ref) => (
<WithSafeNavigation {...props} forwardedRef={ref} />
))
WithForwardRef.displayName = `ForwardRef(WithSafeNavigation)`
return withNavigation(WithForwardRef)
}
export default function createNavigationAwareScrollable(Component: any) {
const ComponentWithNavigationScrolling = withNavigation(
class extends React.PureComponent<any> {
static displayName = `withNavigationScrolling(${Component.displayName ||
Component.name})`;
_subscription: any;
componentDidMount() {
this._subscription = this.props.navigation.addListener(
'refocus',
() => {
const scrollableNode = this.getNode();
if (this.props.navigation.isFocused() && scrollableNode !== null) {
if (scrollableNode.scrollToTop != null) {
scrollableNode.scrollToTop();
} else if (scrollableNode.scrollTo != null) {
scrollableNode.scrollTo({ y: 0 });
return (
<View
style={{
padding: 20,
backgroundColor: getColorOfEvent(this.state.mode),
}}
>
<Text style={{ color: 'white' }}>
{key} {String(this.state.mode)}
</Text>
</View>
);
}
}
const FocusTag = withNavigation(FocusTagWithNav);
class SampleScreen extends React.Component {
static navigationOptions = ({ navigation }) => ({
title: 'Lorem Ipsum',
headerRight: navigation.getParam('nextPage') ? (
<Button
title="Next"
onPress={() => navigation.navigate(navigation.getParam('nextPage'))}
/>
) : null,
});
componentDidMount() {
this.props.navigation.addListener('refocus', () => {
if (this.props.navigation.isFocused()) {
this.scrollView.scrollTo({ x: 0, y: 0 });
? `/${pathAndParams.path}?${queryString.stringify(pathAndParams.params)}`
: `/${pathAndParams.path}`;
return (
<a
href={href}
onClick={e => {
navigation.dispatch(navAction);
e.preventDefault();
}}
>
{children}
</a>
);
}
}
const Link = withNavigation(LinkWithNavigation);
export default Link;