feat: create ActionType context
This commit is contained in:
@@ -6,6 +6,11 @@ interface ProviderProps {
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ActionType {
|
||||||
|
type: 'LOGIN' | 'LOGOUT';
|
||||||
|
payload?: any;
|
||||||
|
}
|
||||||
|
|
||||||
type InitialStateType = {
|
type InitialStateType = {
|
||||||
user: any;
|
user: any;
|
||||||
};
|
};
|
||||||
@@ -22,7 +27,7 @@ const Context = createContext<{
|
|||||||
dispatch: () => null,
|
dispatch: () => null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const reducer = (state: InitialStateType, action) => {
|
const reducer = (state: InitialStateType, action: ActionType) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'LOGIN':
|
case 'LOGIN':
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user