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

ES6 Instructions components #23717

Merged
merged 2 commits into from
Jul 16, 2018
Merged

ES6 Instructions components #23717

merged 2 commits into from
Jul 16, 2018

Conversation

islemaster
Copy link
Contributor

@islemaster islemaster commented Jul 16, 2018

Second attempt to merge #23689. This caused a regression on production the first time we released it. Here's the hotfix revert: #23714.

No known user bad, but it drove our JavaScript error rate high enough to page the DOTD. The reported error was

(TypeError) null is not an object (evaluating 'n.codeWorkspaceContainer.getWrappedInstance')
  at onResize

image
image

We can tell the error is happening here, in the onResize handler of InstructionsWithWorkspace. The issue seems to be that the onResize handler is getting called in a situation where the ref is unbound.

const codeWorkspaceHeight = this.codeWorkspaceContainer
.getWrappedInstance().getRenderedHeight();

After successfully repro'ing this on my local machine and a good deal of trial and error, I discovered that under the original implementation the ref callback was being called on every render, and in maybe 10% of those calls the ref was set to null.

Defining the ref callback once on the component instance instead of within the render method fixes this (the ref callback only happens once when the component mounts). I believe this is because the component sees a new function every time. We've done inline ref callbacks in lots of other places, but in this case it's on CodeWorkspace instead of a React-defined DOMComponent, which may explain the different behavior. I wonder if we've found a bug / edge case in the version of React we are using. In any case, I've verified locally that this fixes the issue.

windowHeight: undefined
};
},
setCodeWorkspaceContainerRef = (element) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@islemaster islemaster requested review from breville and epeach July 16, 2018 22:01
@islemaster islemaster merged commit 4cdb8c6 into staging Jul 16, 2018
@islemaster islemaster deleted the es6-instructions-again branch July 16, 2018 22:05
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.

2 participants