Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

fix: Only update state if mounted. #1081

Merged
merged 1 commit into from
Oct 7, 2020
Merged

fix: Only update state if mounted. #1081

merged 1 commit into from
Oct 7, 2020

Conversation

milesj
Copy link
Contributor

@milesj milesj commented Sep 29, 2020

Motivation

This component always logs error in the console when testing.

Warning: Can't call setState on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the Pager component.

Warning: Can't call forceUpdate on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the Pager component.

PR adds some mounted checks.

Test plan

As long as tests pass and dont log.

Copy link
Owner

@satya164 satya164 left a comment

Choose a reason for hiding this comment

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

Thanks!

@satya164 satya164 changed the title fix(Pager): Only update state if mounted. fix: Only update state if mounted. Oct 7, 2020
@satya164 satya164 merged commit 4f1982c into satya164:master Oct 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants