overleaf/services/web/frontend/js/shared/hooks/use-detach-state-watcher.js
ilkin-overleaf ea2af56f7b Merge pull request #11122 from overleaf/ii-rollback-some-ts-hooks-to-js
[web] Revert detach hooks from TS to JS

GitOrigin-RevId: c108fe219d472f0c0b745dc8648fd15375f0e083
2023-01-10 09:06:14 +00:00

19 lines
404 B
JavaScript

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