Skip to content

Instantly share code, notes, and snippets.

@manoj-mass
Last active July 6, 2021 07:06
Show Gist options
  • Save manoj-mass/fc5f6667c59bceb5f036153b6dac126c to your computer and use it in GitHub Desktop.
Save manoj-mass/fc5f6667c59bceb5f036153b6dac126c to your computer and use it in GitHub Desktop.
import axios from 'axios';
export const ACTION_TYPES = {
SET_HEADERDETAILS: 'SET_HEADERDETAILS',
};
const initialState = {
headerTitle: '',
};
export type HeaderState = Readonly<typeof initialState>;
// Reducer
export default (state: HeaderState = initialState, action): HeaderState => {
switch (action.type) {
case ACTION_TYPES.SET_HEADERDETAILS:
return {
...state,
headerTitle: action.payload.header,
};
default:
return state;
}
};
export const loadHeader: (header: string) => void = header => async (dispatch, getState) => {
await dispatch({
type: ACTION_TYPES.SET_HEADERDETAILS,
payload: { header },
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment