Menu
My Site LogoMy Site LogoDanyal AsifDocsBlogResume
GitHub
🌜
🌞
My Site LogoMy Site LogoDanyal Asif
  • Docs
  • Blog
  • Resume
  • GitHub
  • Introduction
  • Certs And Trainings
  • Algorithms & Data Structures
    • Introduction
    • Bubble Sort
  • Containers
    • Basics
    • orchestration
      • Basics
  • CSS
    • Basics
    • SASS
  • DevOps
    • Introduction
    • AWS
    • DevSecOps
  • draft
  • Flutter
    • Flutter basics
    • Flutter
    • Flutter Input
    • Flutter Navigation
    • Flutter Widgets
  • funstuff
    • Advent of Code - 2019
  • Fun Stuff - Programming for fun
  • javascript
    • JavaScript Debugging
    • Filter Object of Objects
    • Introduction
    • Javascript The Hard Parts
    • JavaScript: The New Hard Parts
    • NPM
    • Object-Oriented Programming
    • referrences
    • Typescript Basics and Stuff
    • Filter arrays for unique objects
  • MobX
  • react
    • React Debugging
    • React
  • react-native
    • expo
      • Push Notifications
    • Expo
    • React Native
    • React Navigation (V4)
  • redux
    • Basics
    • Redux Toolkit
    • Redux Saga
    • Thunk
  • VueJs
    • Introduction
    • Vue Methods
  • websockets
    • SignalR
    • WebRTC
  • YAML

Thunk

Redux Thunk#

npm i -s redux-thunk

Redux out of the box does not the thing to do async.

Thunk is a function that's returned from another function.

function definitelyNotAThunk() {
return function aThunk() {
console.log("Hello, I'm thunk");
}
}
  • Regular Action Creator
export const getAllItems = () => ({
type: UPDATE_ALL_ITEMS,
items,
})
  • Thunking Abstraction
export const getAllItems = () => ({
return dispatch => {
Api.getAll().then(items => {
dispatch({
type: UPDATE_ALL_ITEMS,
items,
})})}})
Previous
« Redux Saga
Next
Introduction »
  • Redux Thunk

Docs

  • Self Documentation

Community

  • Stack Overflow
  • Twitter

More

  • Blog
  • GitHub
Copyright © 2021 My Project, Inc. Built with Docusaurus.