ReactShadow
ReactShadow copied to clipboard
Can useLayoutEffect() be used instead of useEffect() to make rendering synchronous?
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?
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