patrickjames
patrickjames
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
Also I didn’t know that the thing about it automatically memoizing things. I’ll have to read up on that
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
Could you send the exact code you ran?
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
sure
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
hooks are quite dificult to understand at first
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
in some cases it comes from confusion about how they work
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
this makes your app very inefficient
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
yeah a lot of people do not use useMemo and useCallback enough
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
correct
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
in this case generateQrCode() will return a promise
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
well it's going to return whatever you return inside it
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
const qrCode = use(qrCodePromise);
const qrCode = use(qrCodePromise);
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
const qrCodePromise = useMemo(() => generateQrCode(), []);
const qrCodePromise = useMemo(() => generateQrCode(), []);
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
also you wanna wrap the generateQrCode promise result in useMemo so that it isn't executed every time you component is ran
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
he commented it out above his set state line
39 replies
TTCTheo's Typesafe Cult
Created by Wadad Parker on 12/29/2024 in #questions
Data Fetching with React 19
based on what I remember from the documentation, use expects a promise, but you provided a function that returns a promise
39 replies
TTCTheo's Typesafe Cult
Created by BlueBeka on 12/29/2024 in #questions
Is this a safe use of reading a ref during render?
but I would suggest you change the line to popoverRef.current?.hidePopover(); with the optional chaining operator ? instead of ! This is because the parent could potentially call the callback before the component is mounted, which will cause an error in your code due to the ref not being set as yet
9 replies
TTCTheo's Typesafe Cult
Created by BlueBeka on 12/29/2024 in #questions
Is this a safe use of reading a ref during render?
Refs are set after the component code is ran and the element is added to the dom, so I'm guessing the reason eslint is giving you an error in that case is because it has no way of knowing when the line popoverRef.current!.hidePopover(); will actually be called. For all eslint knows, it could be called before the function / render function even returns. If that is the case, the ref will not be set yet and will be null. Eslint is not smart enough to go through your code and find out when that code will be called. If you know for sure that this line of code will only be called after the component is mounted and the ref is set, you can eslint ignore this line. I don't think there is any other way to fix this issue.
9 replies