Hi @jimmylee,
I've been using this repo for about 3 months (since you first released it), and I've been able to fly pretty fast on a side project. So thank you so much for the nice starter kit.
One thing I noticed is that most of the data for all of the pages (comments, posts, etc.) comes from getInitialStateData
from within https://github.com/jimmylee/next-postgres/blob/master/higher-order/withData.js#L9. While I can see why the reasoning behind it, it's not entirely optimal on sites that depend on a lot of data.
I'd like to get your thoughts on patterns to fetch data on a per-page basis that would be SEO friendly.
One solution I have for now is on a (logged in) page, say privacy.js
: is within componentWillMount
doing the fetch and then setting the state for the component based upon what comes back.
E.g.
componentWillMount() {
return this.props.dispatch(Actions.requestGetUserPrivacySettings({
userId: this.props.viewer.id
})).then((settings) => {
this.setState(settings);
});
}
This works, but like I mentioned, I'd like to have something a bit more SEO friendly. I thought about maybe doing it in one of the controllers (within the route) kinda like this:
https://github.com/jimmylee/next-postgres/blob/master/index.js#L39
Where I'd just fetch the data and somehow pass it through to the component, but I'm stuck on how to do that.
Any ideas?