obolus/www/utils/hooks.js
cupcakearmy dcbc4bcdd7 client
2019-05-22 20:34:58 +02:00

12 lines
260 B
JavaScript

import React, { useEffect } from 'react'
export const useLocalStorageWatcher = (fn) => {
useEffect(() => {
window.addEventListener('storage', fn)
return () => {
window.removeEventListener('storage', fn)
}
}, [])
}