Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class CountDown extends React.Component {
until: Math.max(this.props.until, 0),
lastUntil: null,
wentBackgroundAt: null,
appStateSubscription: null
Copy link

@miguelzabalaf miguelzabalaf Sep 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lamonarch87
If you use TypeScript in your project, assign this PropType to appStateSubscription, to avoid warnings when rendering the component:

appStateSubscription: PropTypes.oneOfType([PropTypes.func, PropTypes.object])

};

constructor(props) {
Expand All @@ -51,12 +52,12 @@ class CountDown extends React.Component {
}

componentDidMount() {
AppState.addEventListener('change', this._handleAppStateChange);
this.appStateSubscription = AppState.addEventListener('change', this._handleAppStateChange);
}

componentWillUnmount() {
clearInterval(this.timer);
AppState.removeEventListener('change', this._handleAppStateChange);
this.appStateSubscription.remove();
}

componentDidUpdate(prevProps, prevState) {
Expand Down