Fix react popup unload error

Repository details (talkie)
Project page
talkie
Project log category
(708 entries)
Repository
@joelpurra/talkie
Owner
@joelpurra
Contributors
Contributors on Github
Project status
⏲️ This project has had recent commits.
📂 This project is open.
🌠 This project is popular.
Repository activity period
🗓
Commits
751 commits
Stars
71 stars
Commit details (ad2e4894)
Author
Authored at
Committer
Joel Purra
Committed at

Commit message

Fix react popup unload error

  • Due to async broadcast event listeners, some calls might come very late in the page lifecycle.
  • Not sure what the exact cause is, but guessing it has to do with how browsers unload extension popups.
  • There seems to be a timing where a broadcast event is triggering setState() in such a way that react will try to re-render the content after they have disappeared from the DOM.
  • React has special detection code running in development mode, which may affet the debugging in itself.
  • Adding more checks to try to prevent the error.

See

Raw text
Fix react popup unload error

- Due to async broadcast event listeners, some calls might come very late in the page lifecycle.
- Not sure what the exact cause is, but guessing it has to do with how browsers unload extension popups.
- There seems to be a timing where a broadcast event is triggering `setState()` in such a way that react will try to re-render the content after they have disappeared from the DOM.
- React has special detection code running in development mode, which may affet the debugging in itself.
- Adding more checks to try to prevent the error.

See

- https://github.com/facebook/react/pull/10270
- https://github.com/facebook/react/blob/37e4329bc81def4695211d6e3795a654ef4d84f5/packages/react-reconciler/src/ReactFiberScheduler.js#L770
- https://github.com/facebook/react/blob/46b3c3e4ae0d52565f7ed2344036a22016781ca0/packages/shared/invokeGuardedCallback.js#L151-L161

Changed files (8)

Path Additions Deletions
src/background/background.js +1 -1
src/demo/demo.js +2 -1
src/options/options.js +2 -1
src/popup/hocs/is-speaking.jsx +24 -4
src/popup/hocs/progress.jsx +27 -6
src/popup/popup.js +2 -4
src/shared/hocs/pass-selected-text-to-background.jsx +7 -1
src/stay-alive/stay-alive.js +2 -1

Commit categories (3)