Code Monkey home page Code Monkey logo

Comments (7)

marko-hologram avatar marko-hologram commented on June 22, 2024 4

Client components still run on the server.

https://nextjs.org/docs/app/building-your-application/rendering/client-components

Client Components allow you to write interactive UI that is prerendered on the server and can use client JavaScript to run in the browser.

The term "client component" means that it also runs on the client, not that it just runs on the client exclusively.


Please read the documentation before opening issues like this to make maintainer's life a bit easier πŸ˜„

from next.js.

icyJoseph avatar icyJoseph commented on June 22, 2024 4

As the above comment says, client components are still SSR'd, they are just the components you have used up till now, the new thing are server components, which only render server side, and never share their JS with the client.

* [Why do Client Components get SSR'd to HTML? reactwg/server-components#4](https://github.com/reactwg/server-components/discussions/4)

I can understand the confusion, as the name itself has some weight to it, but also, tech-influencers have spread this misinterpretation.

Your reply don’t solve my problem

This is a bug/issue report area, people here focus on narrowing down reports into a reproducible demo, or a non-issue result. For other matters, we should use the discussions tab.

from next.js.

icyJoseph avatar icyJoseph commented on June 22, 2024 3

Here you go: https://stackblitz.com/edit/github-zvszab?file=app%2Fpage.tsx

from next.js.

icyJoseph avatar icyJoseph commented on June 22, 2024 2

As the above comment says, client components are still SSR'd, they are just the components you have used up till now, the new thing are server components, which only render server side, and never share their JS with the client.

I can understand the confusion, as the name itself has some weight to it, but also, tech-influencers have spread this misinterpretation.

from next.js.

icyJoseph avatar icyJoseph commented on June 22, 2024 2

Hi,

The thing is that, your component render pass should be pure, that's like the main React "rule".

Reading from the window object like that, is not pure, the width might change between renders, so to speak.

So what you can do is:

Also, reading from the window.innerWidth property, causes reflow, https://gist.github.com/paulirish/5d52fb081b3570c81e3a#getting-window-dimensions, which under certain conditions, can be a performance bottleneck.

from next.js.

mirasayon avatar mirasayon commented on June 22, 2024 2

Here you go: https://stackblitz.com/edit/github-zvszab?file=app%2Fpage.tsx

Thanks bro and sorry for opening an issue and bothering you all because of my carelessness.

from next.js.

github-actions avatar github-actions commented on June 22, 2024

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

from next.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.