Comments (2)
@ads1018 I agree with including defaults, so the user can just wrap their component in the HOC without adding anything else special.
This new version of the package changes the approach so that rather than creating a confusing factory function, you add some combination of static methods on your component (getInitialProps, getApolloClient, and getReduxStore). Obviously these can and should be turned into a super component or a HOC by the user so they can be shared on multiple pages. See https://github.com/sbking/next-apollo-example/blob/using-npm-package/pages/index.js
The getInitialProps and getReduxStore static methods are optional as of now. It would be easy to make the getApolloStore method optional as well, perhaps by using an apolloUri prop or something on the component.
When I first started working on this, I found that I was trying to extract out every little configuration you can make into settings passed to the HOC. I'm all for creating some reasonable defaults for getting started with minimal configuration, but I think the approach should generally encourage the user to use the native APIs for production code, in which they should be writing essentially the same apollo / redux code that they would be writing in any other framework, while this package handles the stuff that is specific to next.js.
from next-apollo.
This new version of the package changes the approach so that rather than creating a confusing factory function, you add some combination of static methods on your component (getInitialProps, getApolloClient, and getReduxStore). Obviously these can and should be turned into a super component or a HOC by the user so they can be shared on multiple pages. See https://github.com/sbking/next-apollo-example/blob/using-npm-package/pages/index.js
I'm not sure I completely follow. In your example, it seems you would have to include those static methods on every page you want to fetch data. As well as the configuration files initClient
and initStore
. Is that correct? Or are you saying that example file should be a HOC that lives inside a user's lib
directory?
I'm all for creating some reasonable defaults for getting started with minimal configuration, but I think the approach should generally encourage the user to use the native APIs for production code, in which they should be writing essentially the same apollo / redux code that they would be writing in any other framework, while this package handles the stuff that is specific to next.js.
Agreed.
from next-apollo.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-apollo.