rsnext/packages/next/client/dev/fouc.ts
Gerald Monaco 0fa95da53f
Encapsulate routing and initial hydration (#33875)
* Encapsulate initial rendering

* Run dev code before rendering

* Fix call

* Try reverting last change, fixing call
2022-02-02 09:08:16 -06:00

18 lines
581 B
TypeScript

// This function is used to remove Next.js' no-FOUC styles workaround for using
// `style-loader` in development. It must be called before hydration, or else
// rendering won't have the correct computed values in effects.
export function displayContent(): Promise<void> {
return new Promise((resolve) => {
;(window.requestAnimationFrame || setTimeout)(function () {
for (
var x = document.querySelectorAll('[data-next-hide-fouc]'),
i = x.length;
i--;
) {
x[i].parentNode!.removeChild(x[i])
}
resolve()
})
})
}