ReactShadow icon indicating copy to clipboard operation
ReactShadow copied to clipboard

Can useLayoutEffect() be used instead of useEffect() to make rendering synchronous?

Open gregjacobs opened this issue 4 years ago • 1 comments

In the file https://github.com/Wildhoney/ReactShadow/blob/master/src/core/index.js#L28, the useEffect() hook is used which makes the rendering of the shadow dom element asynchronous. Using useLayoutEffect() instead would make the rendering synchronous.

useEffect() causes a delay in rendering shadow dom elements compared to non-shadow elements. It also affects unit tests where we now need to wait a clock tick until the shadow dom element appears, causing difficult-to-debug tests when we miss this.

Seems like a simple fix?

gregjacobs avatar Jul 29 '21 19:07 gregjacobs

Sure — sounds good @gregjacobs Would you like to open a PR and I can get it merged?

Wildhoney avatar Jul 31 '21 11:07 Wildhoney

I believe this can be closed with #145

TheSharpieOne avatar Jun 16 '23 17:06 TheSharpieOne

Thanks for the heads up @TheSharpieOne

Wildhoney avatar Aug 02 '23 14:08 Wildhoney