-
Notifications
You must be signed in to change notification settings - Fork 26k
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
Is throwing an unnecessary error when getStaticProps & getServerSideProps are undefined #11309
Comments
This behavior will not / should not work by design:
You must export a function. If the above works when you're not mixing the two, we need to issue a patch release to disallow such behavior. |
Ok @Timer ! But why this restriction instead of just ignore when they aren't functions? |
Because getStaticProps en getServerSideProps are tree shaken from browser bundles and what you're trying to do (dynamic assignment) makes it impossible to tree shake it. |
Ok. In that case, it makes sense to me! Thanks to clarifying this @timneutkens |
Is there a way to use them both together? |
Going to close this issue as it's using getStaticProps/getServerSideProps in an unsupported way. @felipenmoura there are some feature requests for a behavior like that but getServerSideProps and getStaticProps are two different methods intentionally, they enable completely different behaviors. |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
When
getStaticProps
andgetServerSideProps
exist both as an export, is throwing an error.Looks OK, however, IMO it should throw this error only when both are functions. With this, it will be possible to use conditional exports.
To Reproduce
Expected behavior
With this:
I expect that
getServerSideProps
is executed becausegetStaticProps
is not defined.With this:
I expect that
getStaticProps
is executed becausegetServerSideProps
is not defined.The text was updated successfully, but these errors were encountered: