overleaf/services/web/frontend/js/shared/hooks/use-detach-state-watcher.js

20 lines
404 B
JavaScript
Raw Normal View History

import { useEffect } from 'react'
import useDetachState from './use-detach-state'
function useDetachStateWatcher(key, stateValue, senderRole, targetRole) {
const [value, setValue] = useDetachState(
key,
stateValue,
senderRole,
targetRole
)
useEffect(() => {
setValue(stateValue)
}, [setValue, stateValue])
return [value, setValue]
}
export default useDetachStateWatcher