TS1308
error TS1308: ‘await’ expressions are only allowed within async functions and at the top levels of modules.ts.
Broken Code ❌
1 |
|
Fixed Code ✔️
You cannot use an await
expression in an useEffect
hook, but you can use legacy Promise calls:
1 |
|
Alternatively, you can use an IIFE (Immediately-invoked Function Expression) in your useEffect
hook:
1 |
|