#I don t get wtf is happening I m
1 messages ยท Page 1 of 1 (latest)
'use client';
import React, { useEffect, useState } from 'react';
export default async function Home() {
const [wtf, setWtf] = useState<any>([['test']]);
useEffect(() => {
setWtf('nooooo');
}, []);
return <pre>{wtf}</pre>;
}
Glad that it is over
and i didn't notice the async
thanks >.<
๐
I'm curious now how the async makes a difference in next's internals
but that's for another day
Yeah, I also make similar mistakes
That's a React internal. Client components cannot be async at the moment and cause VERY erratic behavior.
Also for code related questions please open a thread in #1007476603422527558 in the future.
That is what I would expect
Async functions return promises rather than the usual data type of a React component, so unless there is some weird wizardry I never heard of, I can't think of a way that it could possibly work
Especially in the client side, at least in the server side Next.js is compiling so it can do some pretty weird stuff
It kind of works already, but it's not to be used right now
Oh, okay
That is good news, I don't want to have to use the React-Async library every time I fetch something
The thing is that asynchronous client-side components are pretty useless and have a bunch of possible caveats that haven't even been fully explored yet.
It is a must if the client has to request additional data from the server after the initial page load, no?
Then you just continue using SWR and react-query for client-side data fetching which is a million times better than manually fetching things
Because you get tons of features out of the box you'd have to implement yourself
Caching, invalidation, revalidation on certain events, abort controllers, retries etc.
Oh, I have been using the React-Async library, I will look up what SWR and React-Query are
And reactive updates about the current state
If that one is like a pub-sub pattern, I really need that right now
No, it's not
Oh, okay
Anyways, wrapping up this conversation: async client components have no value right now, it's unclear whether it will be a stable thing in the future and that's it.