Wadad Parker
TTCTheo's Typesafe Cult
•Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
Yes, it's not really about the use API. I just want to know, in the above scenario where we use useState + useEffect, how can we leverage React 19's new Hooks to do the same functionality?
39 replies
TTCTheo's Typesafe Cult
•Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
39 replies
TTCTheo's Typesafe Cult
•Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
This does not work either, it expects the component to be a server component. If use api can only use promises inside a client component. Then that is fine. I just want to know am not doing anything wrong or it's not meant to be used that way.
Regardless, just want to know how would you do that useState + useEffect logic in React 19 for getting a result of a promise
39 replies
TTCTheo's Typesafe Cult
•Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
None the less, this is not about debugging the use api. All I want to know is, how to use the new hooks & apis of React 19 to literally replace the dreaded useState + useEffect code combo for executing a single async function inside a component >_<
39 replies
TTCTheo's Typesafe Cult
•Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
This code does not work, it gives the following error, expecting this to be a server component
react-dom_client.js?v=fbf25467:4472 Uncaught Error: An unsupported type was passed to use(): async () => {
return await QRCode.toDataURL("https://x.com/wadadparker")
Also, React 19 uses React Compiler to already memoize all the variables n functions. Hence it is no longer required to use useMemo. And I did encounter a weird bug of the function running 202 times when I used a useMemo.
39 replies
TTCTheo's Typesafe Cult
•Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
Am not using Typescript, but this is giving runtime error. Breaks the app.
The cb Returns a Data URI containing a representation of the QR Code image. Essentially a longggg data:image/png data uri. And I don't know why the use API would need a type, just returning data, it works fine with normal setState right?
I just want to know if use is not the way, then what should be the React 19 way of refacotoring the above code?
39 replies