DEV Community

Cover image for Day 11: Finished Redux

Posted on

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.


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!

Discussion (1)

fhtyeraw profile image

11 days is something I really want to be able to do
idle mining empire