alexlafroscia / use-task

A React hook for running and cancelling asynchronous tasks
https://use-task.now.sh
24 stars 1 forks source link

Improve behavior around state #14

Closed alexlafroscia closed 5 years ago

alexlafroscia commented 5 years ago

Currently, the task object can be mutated without React actually knowing about it. For example, when a task is cancelled, the isCancelled property is updated, but nothing ever calls setState to let React know that something changed. This means that, if you're binding something to the state of a TaskInstance (which is kind of the whole point of this library), you likely don't get the desired behavior until something else eventually calls setState (such as creation a new task instance).