adobe-photoshop / spaces-design

Adobe Photoshop Design Space
http://adobe-photoshop.github.io/
Other
853 stars 74 forks source link

LayerPanel: cancel forceUpdate when LayerGroup will unmount. #3622

Closed shaoshing closed 8 years ago

shaoshing commented 8 years ago

If you create a document and close it immediately, it will raise an error complaining this.forceUpdate not allowed on a unmounted instance. This PR fixes the error by cancelling the timer callback when the instance is unmounted.

iwehrman commented 8 years ago

I have an additional suggestion: instead of using setTimeout with an arbitrary 2-second timeout, what about using requestIdleCallback instead? That can be canceled similarly, and won't run unless the browser is idle. https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback

What do you think?

shaoshing commented 8 years ago

@iwehrman I actually tried the requestIdleCallback but have to give up the idea because it fires right away and slow down the load time.

iwehrman commented 8 years ago

OK. If you can think of any other way to get rid of this arbitrary timeout, I would really like to get rid of it. The reason is that 2s might work well on your computer, but it might be bad on a much slower or much faster computer.

In any case, this small change looks good!