Setting up the Redux store

Now that we implemented our action types, action creators, and reducers, we need to create the Redux store from our app reducer.

  1. Open src/index.js and clear the contents of the file.
  2. We start by importing the createStore function from the Redux library and our app reducer:
import { createStore } from 'redux'

import appReducer from './reducers'
  1. We also import the createUser and createPost action creators, so we can populate our blog with some sample content:
import { createUser, createPost } from './actions'
  1. Now, we create the store and dispatch some actions:
let store = createStore(appReducer) // create users store.dispatch(createUser('dan', 'Daniel Bugl')) store.dispatch(createUser('des', 'Destiny')) // create ...

Get Learning Redux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.