databag/app/mobile/src/context/useDisplayContext.hook.js

27 lines
570 B
JavaScript
Raw Normal View History

2023-09-05 21:20:47 +00:00
import { useEffect, useContext, useState, useRef } from 'react';
export function useDisplayContext() {
const [state, setState] = useState({
modal: false,
modalTitle: null,
modalCancel: null,
modalOk: null,
});
const updateState = (value) => {
setState((s) => ({ ...s, ...value }))
}
const actions = {
showModal: (modalTitle, modalCancel, modalOk) => {
updateState({ modal: true, modalTitle, modalCancel, modalOk });
},
hideModal: () => {
updateState({ modal: false });
},
};
return { state, actions }
}