Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Remove the warning for setState on unmounted components #323

Merged
merged 11 commits into from
Oct 26, 2021

Conversation

chriscerie
Copy link
Contributor

@chriscerie chriscerie commented Sep 26, 2021

Consistent with upstream React, we should remove the error message when you setState on an unmounted component.

In summary, while it can warn on potential memory leaks, false positives is common and can push people to undesirable workarounds:

function TestComponent:didMount()
    testPromise():andThen(function(newState)
        -- Component might unmount before our promise resolves
        self:setState(newState)
    end)
end

For the full reasoning behind removing the warning, see Dan Abramov's PR: facebook/react#22114

Checklist before submitting:

  • Added entry to CHANGELOG.md
  • Added/updated relevant tests
  • Added/updated documentation

@coveralls
Copy link

coveralls commented Sep 26, 2021

Coverage Status

Coverage decreased (-0.004%) to 94.783% when pulling c6388dd on chriscerie:remove-setstate-warning into 0f26436 on Roblox:master.

@github-actions
Copy link

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Copy link
Contributor

@matthargett matthargett left a comment

Choose a reason for hiding this comment

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

One small nit, overall looks great. Thanks for bringing this upstream React improvement over!

src/Component.lua Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@ZoteTheMighty ZoteTheMighty merged commit 2239e01 into Roblox:master Oct 26, 2021
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.

4 participants