vercel / next-react-server-components

Demo repository for Next.js + React Server Components
https://next-rsc-hn.vercel.app
MIT License
976 stars 156 forks source link

What is the Nav component doing? #48

Closed gabssnake closed 1 year ago

gabssnake commented 1 year ago

Hi everyone,

Thanks for sharing this demo!

I was looking at the source of Nav component:

export default function Nav() {
  ;<ul className="nav-ul">
    <Item href="/newest">new</Item>
    ...

    <style jsx>{`
       ...
    `}</style>
  </ul>
}

Why is this component returning undefined? What does it do if nothing is being returned? How does this have an effect on DOM, state, styles, or anything else? Is this a common pattern? Where can I read more about this? I'm intrigued :)

huozhi commented 1 year ago

It was a clone of hacker news nav bar

image

We hide it in the demo it's because that's not the major point of this demo. We don't want user to be distraced from the main content displaying. It's just not used. We'll clean it up later, thanks for noticing it

gabssnake commented 1 year ago

Thank you for answering. I was afraid it a was a new horrible way of doing invisible things. Turns out it does was it says :)

leerob commented 1 year ago

We brought back the nav when refactoring 😄

https://next-rsc-hn.vercel.app/