Convert useModified into a real hook.
This commit is contained in:
15
src/components/hooks/useModified.ts
Normal file
15
src/components/hooks/useModified.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import useStore from 'store/modified';
|
||||
|
||||
export function useModified(key?: string) {
|
||||
const modified = useStore(state => state?.[key]);
|
||||
|
||||
const touch = (id?: string) => {
|
||||
if (id || key) {
|
||||
useStore.setState({ [id || key]: Date.now() });
|
||||
}
|
||||
};
|
||||
|
||||
return { modified, touch };
|
||||
}
|
||||
|
||||
export default useModified;
|
||||
Reference in New Issue
Block a user