vercel / next.js

The React Framework
https://nextjs.org
MIT License
126.78k stars 26.95k forks source link

Persistent sidebar [Question] #3891

Closed rashidul0405 closed 6 years ago

rashidul0405 commented 6 years ago

We need a sidebar which is a category tree of an e-commerce site, fetched from DB(pls check this example - ffshop : left menu - building the next version of it).

This should only load once - at very first time (server rendered) like react router example

How can I fetch this initially - using HOC? I use layout component and also checked HOC

I think this may be related to #3461, #3552.

next.js match in every aspect of our need but looks like it falls a bit short in this use case. Building another site which also requires rendering dynamic menu from DB. I would like to contribute.

timneutkens commented 6 years ago

Duplicate of https://github.com/zeit/next.js/issues/88

postor commented 6 years ago
rashidul0405 commented 6 years ago

Thank you @postor. For this project, I skipped Redux in favor of unstated (just for global user data etc.). I did this using HOC. just like with-intl example, on server I fetch the data from API and on client read the data from __NEXT_DATA__. So fetch once and reused on every page.