import { useEffect } from 'react' ; export function useChromeStorageChangeListener ( fn ) { useEffect ( ( ) => { function onChange ( changes , namespace ) { if ( namespace !== 'local' ) { return ; } fn ( changes ) ; } chrome . storage . onChanged . addListener ( onChange ) ; return ( ) => { chrome . storage . onChanged . removeListener ( onChange ) ; } ; } , [ fn ] ) ; }