Skip to content

getInitialProps not working on reload (build) #7161

@kpauletti

Description

@kpauletti

Bug report

Describe the bug

The getInitalProps function does not seem to be running on page reload.
I'm trying to pull the id from this path /approaches/view?id=319, it works when I navigate using links, but once I refresh the page the asPath property is now the path without the query, and the query itself is gone. Any ideas?

const ApproachView = props => <TagView {...props} type="approach" plural="approaches" />;

// ApproachView.getInitialProps = async ({ query: { id }, asPath }) => ({ id, asPath });

ApproachView.getInitialProps = async ctx => {
    console.log('get initial props ran!!');

    return { id: ctx.query.id };
};

export default ApproachView;

To Reproduce

Just reloading the page

Expected behavior

Query and path props should persist on reload

System information

  • OS: Linux
  • Browser: Chrome
  • Version of Next.js: 8.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions