mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-30 12:24:25 +02:00
17 lines
429 B
TypeScript
17 lines
429 B
TypeScript
import { merge } from 'lodash'
|
|
import { useLayoutEffect, useRef } from 'react'
|
|
|
|
/**
|
|
* Merge properties with the scope object, for use in Storybook stories
|
|
*/
|
|
export const useScope = (scope: Record<string, unknown>) => {
|
|
const scopeRef = useRef<typeof scope | null>(null)
|
|
if (scopeRef.current === null) {
|
|
scopeRef.current = scope
|
|
}
|
|
|
|
useLayoutEffect(() => {
|
|
merge(window._ide.$scope, scopeRef.current)
|
|
}, [])
|
|
}
|