mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-20 07:41:22 +02:00
Refactor desktop app into separate client and proxy apps
This commit is contained in:
14
apps/yaak-client/hooks/useStateWithDeps.ts
Normal file
14
apps/yaak-client/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 | (() => T), deps: DependencyList) {
|
||||
const [value, setValue] = useState(defaultValue);
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: none
|
||||
useEffect(() => {
|
||||
setValue(defaultValue);
|
||||
}, [...deps]);
|
||||
return [value, setValue] as const;
|
||||
}
|
||||
Reference in New Issue
Block a user