-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
findDOMNode() throws inside Suspense #14188
Comments
Can you test if it works on master? |
Nope, it's broken on master, and after bisecting, I confirmed the regression was caused by #14083 EDIT: Something else I found is that before the regression, EDIT 2: Yeah, const React = require("react");
const ReactDOM = require("react-dom");
const ReactTestRenderer = require("react-test-renderer");
const { Suspense } = React;
let didSuspend = false;
function Suspend() {
if (!didSuspend)
throw {
then() {
didSuspend = true;
}
};
return null;
}
class Component extends React.Component {
componentDidUpdate() {
ReactDOM.findDOMNode(this);
}
render() {
return null;
}
}
function App() {
return (
<Suspense fallback="Loading">
<Component />
<Suspend />
</Suspense>
);
}
const root = ReactTestRenderer.create(<App />);
root.update(<App />); This is true both before and after the aforementioned PR, so in any case it looks like it helped us discover this 😄 |
This sounds like a separate problem, can you provide a test case for it? |
Here's a minimal repro with ReactDOM: const Lazy = React.lazy(() => new Promise(resolve => resolve({
default() {
return 'hello';
}
})))
class Child extends React.Component {
componentDidUpdate() {
ReactDOM.findDOMNode(this);
}
render() {
return null;
}
}
class App extends React.Component {
state = {
suspend: false
};
handleClick = () => {
this.setState({ suspend: true });
};
render() {
return (
<React.Suspense fallback="Loading">
<Child />
<button onClick={this.handleClick}>Suspend</button>
<Child />
{this.state.suspend && <Lazy />}
</React.Suspense>
);
}
}
ReactDOM.render(
<App />,
document.getElementById('container')
); |
Okay, so a part of this is covered by #14197. It got first broken by #14083 and got fixed in #14164. However I think repro case in #14188 (comment) might be a separate issue. Looking into it. |
Welp, turns out I'm wrong, I actually made a mistake when mocking |
Another reproducible example: https://codesandbox.io/s/zwzqp18ool When does it throw:
|
This was likely fixed in #15312. Can you verify on master? |
Yes, current |
This will get into the next release then. |
@gaearon @acdlite, User report reproduce: https://codesandbox.io/s/antd-reproduction-template-sbsiz ref: ant-design/ant-design#17016 Update: Create a mini reproduce about this: #15857 |
Sorry, we didn’t release the fix yet. |
@gaearon any ETA on when this will be available? |
We are blocked by this, too (without a pretty significant workaround). Any sense of a release timeframe? @gaearon? Is there some way to find out (in general) when the "next" release is? Sorry if this is covered somewhere.. For the record, this is surfacing for us through Semantic UI React Dropdown. So we're beholden to them as well, but they point us here for the fix. :) |
any new updates? |
We've published |
(You should still ask packages to migrate away from |
16.9.0 hadn't fix this bug! |
@MissLlq All reproductions linked in this issue (https://codesandbox.io/s/zwzqp18ool and https://codesandbox.io/s/n4241q075l) no longer crash with 16.9. If you still encounter this error message with 16.9 please open a new issue. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
I have a component which listens for resize events (via a BlueprintJS ResizeSensor). When loading a component dynamically with
lazy
/Suspense
, an exception occurs as the resize sensor appears to be unmounted:The resize sensor should be removing listeners on unmount.
Demo: https://codesandbox.io/s/n4241q075l
Related: palantir/blueprint#3141
What is the expected behavior?
No exception is thrown.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Tested with:
The text was updated successfully, but these errors were encountered: