Skip to content
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

When using getServerSideProps with addHookData the page loses the usePost info #774

Closed
1 task done
Knskan3 opened this issue May 21, 2024 · 2 comments
Closed
1 task done

Comments

@Knskan3
Copy link

Knskan3 commented May 21, 2024

Describe the bug

When using getServerSideProps with addHookData the page loses the usePost info

Steps to Reproduce

Context:

  • using getServerSideProps (full SSR site)
  • I have to extend the addHookData with props to manually inject theusePost result, otherwise, it's removed.
Screenshot 2024-05-21 at 07 47 05

Screenshots, screen recording, code snippet

No response

Environment information

No response

WordPress information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@nicholasio
Copy link
Member

When you say "the page loses the usePost info" do you mean you are not able to use usePost hook?

By design you should not be able to access the post data directly from props but only from the hooks.

@nicholasio
Copy link
Member

In the pages router, you need to pass the exact same params both on the server and on the client, see the example here: https://github.com/10up/headstartwp/blob/develop/projects/wp-nextjs/src/pages/%5B...path%5D.tsx#L106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants