devvit icon indicating copy to clipboard operation
devvit copied to clipboard

setState should clearly error within useAsync

Open PitchforkAssistant opened this issue 8 months ago • 0 comments

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/

PitchforkAssistant avatar Apr 10 '25 18:04 PitchforkAssistant