Initial commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
const createStep = (type, params = {}) => {
|
||||
if (!type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
type,
|
||||
params,
|
||||
};
|
||||
};
|
||||
|
||||
export default (initialType, initialParams) => {
|
||||
const [step, setStep] = useState(() => createStep(initialType, initialParams));
|
||||
|
||||
const openStep = useCallback((type, params) => {
|
||||
setStep(createStep(type, params));
|
||||
}, []);
|
||||
|
||||
const handleBack = useCallback(() => {
|
||||
setStep(null);
|
||||
}, []);
|
||||
|
||||
return [step, openStep, handleBack];
|
||||
};
|
||||
Reference in New Issue
Block a user