-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Route to new page without invoking getInitialProps
#8774
Comments
getInitialProps
(shallow routing to new page)getInitialProps
I have the same problem, @brettinternet , what's your workaround so far? Could you explain more about it? Thanks |
My workaround is
|
@dmks I’m excited to try this. It’s been working for you well? Where does |
Yes, here is the source code: |
Unfortunately, turns out this doesn't seem to always grab the |
@dmks I'm not able to reproduce this (CodeSandbox). Could you provide an example? |
@brettinternet , your sandbox is not using the "static export" function of nextjs, right? Maybe we are talking about different scenarios, mine is this:
When I enter the url on the navigation bar on my browser, the behavior is different for different environment.
And my workaround is to solving the #2 issue, I don't want |
Related: #9524 |
Closing as duplicate of #9524 |
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. |
Feature request
When using a
next export
static build, I would like thegetInitialProps
method to fire only during the build step and not on the client for select page components. (Related StackOverflow question)On a static client, Next.js invokes this method before the page component is rendered in order to provide the necessary props for the component. Thus, large requests can delay the client's first paint as this is a blocking request.
I would like to selectively ignore
getInitialProps
for a page component, and instead use the props provided bygetInitialProps
duringnext export
.I'm unwilling to move my slow API request to
componentDidMount
in order to avoid the blocking request because I want to use the data returned during the build step to populate the static HTML, and this particular request doesn't need to be dynamic or updated after the build.- Shallow Routing
For this feature request, is it possible to implement something similar to shallow routing, but for new pages?
To circumvent
getInitialProps
on static exports, I currently have to use a standard JSX anchor<a href="/next-page">
to avoid invoking the method. This does cause a full page refresh which is a poor solution.The text was updated successfully, but these errors were encountered: