mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-23 01:49:13 +01:00
Hide large GRPC messages by default
This commit is contained in:
14
src-web/hooks/useStateWithDeps.ts
Normal file
14
src-web/hooks/useStateWithDeps.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { DependencyList } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
/**
|
||||
* Like useState, except it will update the value when the default value changes
|
||||
*/
|
||||
export function useStateWithDeps<T>(defaultValue: T, deps: DependencyList) {
|
||||
const [value, setValue] = useState(defaultValue);
|
||||
useEffect(() => {
|
||||
setValue(defaultValue);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, deps);
|
||||
return [value, setValue] as const;
|
||||
}
|
||||
Reference in New Issue
Block a user