-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Providing Higher Order Functions for common getServerSideProps scenarios #7
Comments
So basically it's just about converting the utility functions ( Are there any other improvements to the DX that we can make with these? 🤔 UPD: I see that it would help to make scenarios like this one a bit cleaner, so that sound like a great idea actually. Although I would still allow using the current |
Anything. For example, typically fetched page props can be done with a HOF and passed to the wrapped function as a second argument (or alternatively within the context object): export const getServerSideProps: GetServerSideProps<BasePageProps> = withStoryPageProps(async (context, props) => {
const { story, translations, languages, newsroom, theme, preset } = props;
const discourseUrl = ...;
return {
props: {
...props,
discourseUrl,
};
};
}); |
This was kind of addressed in #31 (although not in a HOF way). |
I had this idea with this package providing higher-order functions to provide extended context to the wrapped
getServerSideProps
function to simplify common scenarios.An example using such approach with HTTP env headers and Prezly API client:
and then the usage will be something like this:
what do guys you think about this approach?
The text was updated successfully, but these errors were encountered: