Replies: 4 comments 9 replies
-
@deo002 Please can you write the PDF in .md format here ? |
Beta Was this translation helpful? Give feedback.
-
@heliocastro @deo002 I have a comment that using useEffect in the client components is necessary, it will help us control which functions will run when the state changes, not all functions. We shouldn't try to remove useEffect in client components. There is a problem with useEffect that it will run twice. This problem occurs due to react strict mode and it only occurs in development mode (in production mode useEffect run once only). We can disable it by adding |
Beta Was this translation helpful? Give feedback.
-
Nothing against useEffect. Just against use it together with Fetch process. For getSession inside fetch, i'm not totally buying it, as we will end up in a concurrency issues. Worth try though. |
Beta Was this translation helpful? Give feedback.
-
@deo002 @heliocastro, we can try use hook, then we don't need to fetch in useEffect anymore. Like this
I found this from this blog |
Beta Was this translation helpful? Give feedback.
-
Proposal: Refactor of SW360 UI to Render Appropriate Components Server-Side
Introduction
NextJS now supports React Server Components (abbreviated RSC) using the new app directory. RSCs give us a huge advantage over the Client Site Rendered Apps and the Server-Side Rendered Apps.
Client Side Rendered Applications are very interactive (i.e., we can use React state hooks and immediately update UI) and give access to Browser APIs.
The Server Side Rendered Applications provide several benefits such as Server-Side Data Fetching (closer to data source so low latency and no dealing with complex state management with UseEffect), caching components on server, reduces client JavaScript bundle size, faster initial page load and many more.
RSC allows us to have the best of both worlds by letting us decide which part of our code will run where (server-side or client side).
More on this:
Here’s what NextJS says on when to use client components and server components:
Current Flow and Drawbacks:
Currently, most of our components are client side rendered.
Drawbacks:
Proposed Flow:
Render appropriate components server-side. For example, let’s take the case of Vulnerability Detail’s page:
More on Client and Server composition patterns: https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns
Beta Was this translation helpful? Give feedback.
All reactions