JS-Redux: Redux Store And action.type Properties

Create a Redux Store

const reducer = (state = 5) => {
return state;
}
const store=Redux.createStore(reducer)

Get State from the Redux Store

const store = Redux.createStore(
(state = 5) => state
);

const currentState=store.getState()

Define a Redux Action

const action={type:'LOGIN'}


Define an Action Creator

const action = {
type: 'LOGIN'
}

function actionCreator(){
return action
}

Dispatch an Action Event

const store = Redux.createStore(
(state = {login: false}) => state
);

const loginAction = () => {
return {
type: 'LOGIN'
}
};

store.dispatch(loginAction ());
store.dispatch({ type: 'LOGIN' });


Comments

Popular posts from this blog

Tech Duos For Web Development

CIFAR-10 Dataset Classification Using Convolutional Neural Networks (CNNs) With PyTorch

Long-short-term-memory (LSTM) Word Prediction With PyTorch