Create a React app using Webpack 5 + Babel + Karma + Redux (Part 2: REDUX)

export const INCREMENT = "INCREMENT"; 
export const DECREMENT = "DECREMENT";
export const increaseCounter = () => {
return {
type: INCREMENT,
}

};
const counterReducer = (state = INITIAL_STATE, action) => {
switch (action.type) {
case INCREMENT:
return {
...state,
count: state.count + 1,
};
case DECREMENT:
return {
...state,
count: state.count - 1,
};
default:
return state;
}};
npm install react-redux redux
//index.js
import { combineReducers } from "redux";
const reducers = combineReducers({
// our app reducers
//counter: counterReducer <-- will be added later
})
export default reducers;
//store.js
import { createStore } from "redux";
import reducers from ".";
const store = createStore(reducers);
export default store;
import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import "./index.scss";
import store from "./reducers/store";
export const App = () => {
return (<h1>Hello World!</h1>);
};
if (document.querySelector("#root")) {
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>

, document.querySelector("#root"));
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store