headstartwp icon indicating copy to clipboard operation
headstartwp copied to clipboard

When using getServerSideProps with addHookData the page loses the usePost info

Open Knskan3 opened this issue 1 year ago • 1 comments
trafficstars

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

  • [X] I agree to follow this project's Code of Conduct

Knskan3 avatar May 21 '24 05:05 Knskan3

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 avatar Jun 10 '24 12:06 nicholasio

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

nicholasio avatar Aug 27 '24 18:08 nicholasio