Day 11: Finished Redux

kemystra

Kemystra

Posted on April 16, 2022

Day 11: Finished Redux

The Fyeamn tehcinuqe syas taht taecinhg a sbujcet makes you better at it, which is what I'm trying to do here. You may correct me if you saw mistakes in this post

Asynchronous Data

Handling data that don't come on time is annoying (much like that one friend who's always late). Redux can't handle asynchronous data by itself. Instead you need yet another software to achieve this, the aptly named middleware.

Here, we will use Redux Thunk:

let store = Redux.createStore(reducerFunction, ReduxThunk.default);
Enter fullscreen mode Exit fullscreen mode

This is to include Redux Thunk into our project.

To update states asynchronously, we need to design a special action creator:

const actionCreator = () => {
  return function(dispatch) => {
    // You can dispatch loading action here
    // Here you can get the data
    // And then call an action, updating the state with the data
  }
};
Enter fullscreen mode Exit fullscreen mode

Note that the dispatch argument is mandatory.

State immutability

Redux DON'T force you to make the state immutable. However, you should.

Keep this in mind when you are working with arrays or objects.

Afterwords

I'm writing this during a very heavy rain, and I panicked a bit when the internet dropped 😵. Luckily it came back (Well, you won't be seeing this post if doesn't).

I didn't learn a lot today, the circumstances of today really took a hit on my energy. Anyway, good luck to other people going through this challenge 😇. I need to catch my sleep 😴.

Follow me on Github!
Also on Twitter!

💖 💪 🙅 🚩
kemystra
Kemystra

Posted on April 16, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Day 11: Finished Redux
100daysofcode Day 11: Finished Redux

April 16, 2022