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

A couple of small performance related issues #554

Open
avoskresensky opened this issue Apr 16, 2021 · 1 comment · May be fixed by #556
Open

A couple of small performance related issues #554

avoskresensky opened this issue Apr 16, 2021 · 1 comment · May be fixed by #556

Comments

@avoskresensky
Copy link

We're working on polishing our product performance-wise, and have identified a couple of small issues with this (awesome!) library that we'd like you guys to address. Luckily, both are pretty trivial to fix:

image

This one originates here:
https://github.com/react-grid-layout/react-draggable/blob/master/lib/Draggable.js#L239

An unconditional setState in a lifecycle. Something like this would fix that:

componentWillUnmount() {
    if (this.state.dragging) {
        this.setState({dragging: false}); // prevents invariant if unmounted while dragging
    }
}

Sometimes we get "forced reflow" alerts like these:

image

Those originates here:
https://github.com/react-grid-layout/react-draggable/blob/master/lib/DraggableCore.js#L261

Wrapping the DOM mutation in a rAF would fix that:

if (this.props.enableUserSelectHack) {
    requestAnimationFrame(() => {
        removeUserSelectStyles(ownerDocument);
    });
}
@STRML
Copy link
Collaborator

STRML commented Apr 16, 2021

Sounds good, could you submit a PR for these changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants