Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiIcon] Correct isMounted logic #6166

Merged
merged 2 commits into from
Aug 24, 2022

Conversation

chandlerprall
Copy link
Contributor

@chandlerprall chandlerprall commented Aug 23, 2022

Summary

Fixes #6099

React.StrictMode, used by Create React App & others, does interesting things around component creation, mounting, and re-use in development mode to enforce lifecycle best practices. EuiIcon was setting its isMounted property in the wrong place which led to no icons loading in some development environments (I was never able to reproduce the issue in EUI docs), as StrictMode would mount->unmount->mount components, causing EuiIcon to throw away the async icon when it loaded.

I tested this by manually changing node_modules/@elastic/eui in a create-react-app, and confirmed the change (also applied manually) resolved this issue in an internal Elastic project.

Checklist

- [ ] Checked in both light and dark modes
- [ ] Checked in mobile
- [ ] Checked in Chrome, Safari, Edge, and Firefox
- [ ] Props have proper autodocs and playground toggles
- [ ] Added documentation
- [ ] Checked Code Sandbox works for any docs examples
- [ ] Added or updated jest and cypress tests

  • Checked for breaking changes and labeled appropriately
    - [ ] Checked for accessibility including keyboard-only and screenreader modes
    - [ ] Updated the Figma library counterpart
  • A changelog entry exists and is marked appropriately

@chandlerprall chandlerprall requested a review from cee-chen August 23, 2022 21:52
Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

Super great catch and a very elegant fix! This seems extremely sane to me and I trust your testing, but let me know if you want me to attempt to repro/confirm the fix

@chandlerprall
Copy link
Contributor Author

Super great catch and a very elegant fix! This seems extremely sane to me and I trust your testing, but let me know if you want me to attempt to repro/confirm the fix

I'll do a final test build & drop it in CRA before merging 👍

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6166/

@chandlerprall
Copy link
Contributor Author

Pointed the failing CRA project at a recompiled EUI, icons now load.

@chandlerprall chandlerprall merged commit 3da20f8 into elastic:main Aug 24, 2022
@chandlerprall chandlerprall deleted the bug/6099-icons-not-loading branch August 24, 2022 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Icons not loading when page loads
3 participants