databag/net/web/src/AppContext/useGroupContext.hook.js

29 lines
489 B
JavaScript
Raw Normal View History

2022-04-24 02:49:27 +00:00
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 }
}