Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Fix error ResizeObserver loop limit exceeded #1647

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Cerner Corporation
- Tom Wu [@tomleewu]
- Cory McDonald [@corymcdonald]
- Anthony Ross [@AnthonyRoss]
- Ajay Philip Sabu [@ap056120]

[@ryanthemanuel]: https://github.com/ryanthemanuel
[@Matt-Butler]: https://github.com/Matt-Butler
Expand Down Expand Up @@ -132,3 +133,4 @@ Cerner Corporation
[@tomleewu]: https:/github.com/tomleewu
[@CoryMcDonald]: https://github.com/CoryMcDonald
[@AnthonyRoss]: https://github.com/AnthonyRoss
[@ap056120]: https://github.com/ap056120
5 changes: 5 additions & 0 deletions packages/terra-responsive-element/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog
Unreleased
----------

3.2.0 - (June 25, 2018)
------------------
### Fixed
* Fixed ResizeObserver loop limit exceeded error for Responsive Elements

3.1.0 - (June 22, 2018)
------------------
### Changed
Expand Down
6 changes: 5 additions & 1 deletion packages/terra-responsive-element/src/ResponsiveElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ class ResponsiveElement extends React.Component {

componentDidMount() {
if (this.container) {
this.resizeObserver = new ResizeObserver((entries) => { this.handleResize(entries[0].contentRect.width); });
this.resizeObserver = new ResizeObserver((entries) => {
window.requestAnimationFrame(() => {
this.handleResize(entries[0].contentRect.width);
});
});
this.resizeObserver.observe(this.container);
} else {
this.handleResize(window.innerWidth);
Expand Down