mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 19:49:16 +00:00
29 lines
489 B
JavaScript
29 lines
489 B
JavaScript
|
import { useEffect, useState, useRef } from 'react';
|
||
|
|
||
|
export function useGroupContext() {
|
||
|
const [state, setState] = useState({
|
||
|
token: null,
|
||
|
revision: 0,
|
||
|
});
|
||
|
|
||
|
useEffect(() => {
|
||
|
}, []);
|
||
|
|
||
|
const updateState = (value) => {
|
||
|
setState((s) => ({ ...s, ...value }))
|
||
|
}
|
||
|
|
||
|
const actions = {
|
||
|
setToken: async (token) => {
|
||
|
updateState({ token });
|
||
|
},
|
||
|
setRevision: async (revision) => {
|
||
|
updateState({ revision });
|
||
|
},
|
||
|
}
|
||
|
|
||
|
return { state, actions }
|
||
|
}
|
||
|
|
||
|
|