most
This commit is contained in:
@@ -4,15 +4,23 @@ export default function useLayoutInit() {
|
||||
const initialized = useRef(false)
|
||||
|
||||
useEffect(() => {
|
||||
// Dual guard: useRef + window.__rakarInit
|
||||
// useRef protects against re-renders in same mount cycle
|
||||
// window.__rakarInit protects against React 19 strict mode
|
||||
// unmount/remount cycle where useRef may be reset
|
||||
if (initialized.current) return
|
||||
initialized.current = true
|
||||
if (window.__rakarInit) return
|
||||
let destroyed = false
|
||||
let rafId = null
|
||||
|
||||
function tryInit() {
|
||||
if (destroyed) return false
|
||||
if (typeof window.rakar_content_load_scripts === 'function') {
|
||||
window.rakar_content_load_scripts()
|
||||
if (!window.__rakarInit) {
|
||||
window.__rakarInit = true
|
||||
window.rakar_content_load_scripts()
|
||||
}
|
||||
window.__layoutReady = true
|
||||
window.dispatchEvent(new Event('layout-ready'))
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user