Thunk

/θʌŋk/ · Noun · Development

Definitions

  1. A function that wraps an expression to delay its evaluation until the result is actually needed. In Redux, a thunk is an action creator that returns a function (instead of a plain action object) enabling async dispatch of side effects like API calls.

    In plain English: A wrapper function that postpones doing work until someone actually asks for the result.

    Example: "The fetchUser thunk dispatches a loading action, awaits the API call, then dispatches success or failure."

Related Terms