mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-05-24 17:23:39 +08:00
chore: migrate to monorepo
This commit is contained in:
@@ -2,14 +2,12 @@ import React from 'react';
|
||||
import hoistStatics from 'hoist-non-react-statics';
|
||||
import { withNavigation } from '@react-navigation/core';
|
||||
|
||||
export default function createNavigationAwareScrollable(Component: any) {
|
||||
export default function createNavigationAwareScrollable(Component) {
|
||||
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',
|
||||
@@ -28,6 +26,12 @@ export default function createNavigationAwareScrollable(Component: any) {
|
||||
);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this._subscription != null) {
|
||||
this._subscription.remove();
|
||||
}
|
||||
}
|
||||
|
||||
getNode() {
|
||||
if (this._scrollRef === null) {
|
||||
return null;
|
||||
@@ -42,12 +46,6 @@ export default function createNavigationAwareScrollable(Component: any) {
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this._subscription != null) {
|
||||
this._subscription.remove();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Component
|
||||
|
||||
Reference in New Issue
Block a user