mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
23 lines
391 B
JavaScript
23 lines
391 B
JavaScript
|
import { useEffect } from 'react'
|
||
|
import useDetachState from './use-detach-state'
|
||
|
|
||
|
export default function useDetachStateWatcher(
|
||
|
key,
|
||
|
stateValue,
|
||
|
senderRole,
|
||
|
targetRole
|
||
|
) {
|
||
|
const [value, setValue] = useDetachState(
|
||
|
key,
|
||
|
stateValue,
|
||
|
senderRole,
|
||
|
targetRole
|
||
|
)
|
||
|
|
||
|
useEffect(() => {
|
||
|
setValue(stateValue)
|
||
|
}, [setValue, stateValue])
|
||
|
|
||
|
return [value, setValue]
|
||
|
}
|