re-rxjs / react-rxjs

React bindings for RxJS
https://react-rxjs.org
MIT License
555 stars 20 forks source link

Server side rendering is missing `getServerSnapshot` #292

Closed ink-su closed 1 year ago

ink-su commented 1 year ago

Hi hi, this library looks very cool.

I tried this example https://react-rxjs.org/docs/getting-started#create-a-hook-from-an-observable with SSR using NextJS.

The following error shows up. Error: Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering.

Would it be possible to put add a way to set a default value as the third argument to: useSyncExternalStore?

Jimmy89 commented 1 year ago

I had the same issue and I figured out I forgot to add the Subscribe wrapper around my parent jsx component.

For example:

import { Subscribe } from "@react-rxjs/core"

function Root() {
  return (
    <div>
      <Subscribe>
        <ChildWithBindedObserver />
      </Subscribe>
    </div>
  )
}
ink-su commented 1 year ago

Oops I missed that 👍 Thanks for the tip