#useEffect for server side?
18 messages · Page 1 of 1 (latest)
What exactly would you try to accomplish with that?
I want to render data from api in SSR, i use client side before using axios, and i want to try for SSR
If you r using ssr, thats under the pressumption that you would need to prepare the data before running client code..
Theres no useeffect in server, you just directly put the method in server component and that would be run once when server components are prerendered in the server
I've tried getServerSideProps() just to print simple hello text, but it doesn't work, file in app/result/page.jsx when i access localhost/result it just empty page. ```import React from "react";
const A = ({ a }) => {
return (
<div>
<p>{a}</p>
</div>
);
};
export async function getServerSideProps() {
const a = "hellooo";
return {
props: { a },
};
}
export default A; ```
Are you ysing pages folder?
I use app folder
If ure using app folder, you dont need to use GetServerSideProps anymore
Component in App folders are server component by default
So just type A inside div it will be ssr'd
Or get any data using await
I see, so to fetch data from api server just use await? no need axios right?
Yes, id only use axios for client side fetching
Look up the data fetching in the docs
So all files in app folder is already SSR?
Yes, unless explicitlt stated otherwise (or imported to a client component)
Explicitly
I've lookup the docs, but there's misunderstood