Skip to content
This repository has been archived by the owner on Apr 30, 2023. It is now read-only.

Thunk example #8

Closed
wants to merge 5 commits into from
Closed

Thunk example #8

wants to merge 5 commits into from

Conversation

albseb511
Copy link

@albseb511 albseb511 commented Mar 3, 2020

I added a thunk example based on redux toolkit docs:

  • I added it for 2 secs. With a loading indicator. I have kept a placeholder error message, although I have not added it to the component. Made a promise with for sleep 2 sec.
  • I have added the dependencies for thunk to package.json and template.json. (let me know if this is alright)
  • added an isLoading variable and changes the button text to loading
  • added an error variable. Although this is not used in the component
  • added a 10px margin-bottom to the row class

This was referenced Mar 3, 2020
@markerikson
Copy link
Contributor

RTK already includes thunks by default, so you don't have to add that as a listed dependency.

I'm also not sure how many more examples we actually need in the template at this point.

@ryota-murakami
Copy link

ryota-murakami commented Mar 3, 2020

thunks is one of most simple middlewares in redux, and thinks most highly demand periods are coming async/await syntax commonly I guess.

Thunk is still preferable way in redux world, that example is worth it though.

I think thunk was created assuming on 7 years ago web dev environment :)

@ryota-murakami
Copy link

This is no offense, I think your example is good, helpful enough :)

@albseb511
Copy link
Author

albseb511 commented Mar 4, 2020

@markerikson

Hey my bad, I fixed that.

I believe any new user on Redux as they learn React struggle with the concept of thunk. Its ironic that the source code is barely 10 lines. It's a mental block and I have seen a lot of people tend to skip this till they are forced to learn. (source: my students. :P)

I think its important to see how simple it is to use.

gif

@ryota-murakami thanks!

@albseb511
Copy link
Author

@markerikson any comments on this, or should this be closed?

@markerikson
Copy link
Contributor

I think I'm going to go with the changes in #10 instead. Thanks anyway!

@markerikson markerikson closed this Mar 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants