jaredpalmer/after.js

How can I add getInitialProps to Layout Component (layout-component example)

Closed this issue · 7 comments

❓Question

Thanks for the library. Really cool !!!

Layout component by default doesn't get getInitialProps method. Is there any way to get it in it
There should be request with initial project data (is authenticated user, some settings )

I use razzle.js.
Nested routes would help. Is any example of it?

nested routes are not supported yet.
there is no official support for Layout component getInitalProps!. (but I can help you to implement it easily)

@nimaa77 I had seen roadmap (after.js 4.0). This version of library will get nested routes functionality.
When this release is planing ?

It would be good if you gave me some example of no official support for Layout component getInitalProps
I know, I can request initial data from Document.js and server.js, but maybe is better way ?

Thank you!

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

nested routes are not supported yet. there is no official support for Layout component getInitalProps!. (but I can help you to implement it easily)

Would you be able to show me how to have getInitialProps inside of the Layout component? I have tried to add a getInitialProps function to my Layout component and then call it from within the getInitialProps function of Document which works however the data I am returning from the Layout component is not passed to the client side

@Yamaha32088 There is weak support here, I do not recommend using razzle and after js.
next js will be better to use

@Volodymyrkohut I would love to do that but we have a very large project that was built using Razzle and After.js that likely isn't going to be approved to convert to Next.js anytime soon.