setState should clearly error within useAsync

Open
#176 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
frontend

Research direction

Start by locating the useAsync entry point and reviewing the documentation that currently warns about state use inside data-fetch functions. Trace how setState calls are handled there and identify the existing tests for useAsync behavior. Done means an in-scope setState call produces a clear error rather than being silently ignored, with the documentation updated if needed.

Written by the indexing model from the issue text.

Description

blocks

It appears that set state calls inside of useAsync data fetch functions are silently ignored.

Issues with using state inside of the useAsync function are mentioned in the docs, but it is clearly not visible enough, as many devs have unknowingly ran into this issue.

I think the best solution would be to throw an error if a set state function is called in useAsync.

Reddit thread regarding this: https://www.reddit.com/r/Devvit/comments/1jrjtp6/blocks_psa_dont_use_setstate_within_useasync/

Dominant language
TypeScript
Stars
210
Forks
88
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from reddit/devvit

All issues in reddit/devvit

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.