Closed gregjacobs closed 1 year ago
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()
useLayoutEffect()
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?
Sure — sounds good @gregjacobs Would you like to open a PR and I can get it merged?
I believe this can be closed with #145
Thanks for the heads up @TheSharpieOne
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. UsinguseLayoutEffect()
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?