Connecting the store

In order to connect the store to our application we need to use the StoreProvider component.

Simply wrap the application with the StoreProvider, providing the store instance to it.

Wrapping your application

Firstly, we will import the StoreProvider and our store instance.

// src/index.js

import { StoreProvider } from 'easy-peasy';
import store from './store';

Then then wrap our application.

// src/index.js

ReactDOM.render(
  <StoreProvider store={store}>
    <App />
  </StoreProvider>,
  rootElement
);

Review

Awesome, the store is now exposed to the application.

Next up we will refactor our components to consume the state from the store.

You can view the progress of our application refactor here.