Member-only story
Learn redux-optimist
Simplify optimistic rendering with redux-optimist library
3 min readDec 14, 2019
The redux-optimist library has been extremely helpful to me, and I’d like to share that with you. I’ve designed a simple tutorial where I’ll walk you through how to set up and use the middleware. We’re going to use a sweet Pokémon API as our demo practice. We’ll fetch this Pikachu and optimistically evolve it to Raichu. If the request fails, then we’ll devolve back to Pikachu.
- Let’s install the dependencies we need, in your terminal:
yarn create react-app app-name
cd app-name
yarn add react-dom
yarn add react-router-dom
yarn add react-redux
yarn add redux
yarn add redux-thunk
yarn add lodash
- Follow along to set up Redux, or skip ahead to step 3 if you have your own preferred Redux setup.
a. open src/index.js
b. Create action file, in your terminal: touch src/pokemonActions.js && open src/pokemonActions.js