Relay: Concern about unstable_read and SSR

Created on 7 Oct 2018  路  3Comments  路  Source: facebook/relay

Hi there,

@TrySound brought up a good point in this comment about how SSR wouldn't work for components where unstable_read is being used.

It seems to be best to revert the change back to use <ReactRelayContext.Consumer> and use unstable_read in the relay-experimental package.

@TrySound provided a codesandbox repo to show how unstable_read breaks SSR: https://codesandbox.io/s/l5j35928xl

Thoughts?

Most helpful comment

Thanks for bringing this up @johntran, @TrySound. React is actually going to remove unstable_read, so we will end updating this in a way that is also SSR compatible

All 3 comments

cc @jstejada

Thanks for bringing this up @johntran, @TrySound. React is actually going to remove unstable_read, so we will end updating this in a way that is also SSR compatible

Well, it's not quite removed. It's hidden in react internals. Libraries still can use it for own purpose. For example in relay it would be nice to have an api without render props and HOCs like this

const fragment = createFragment(
  graphql``
)

const Component = props => {
  const user = fragment.read(props.user)
  return null
}
Was this page helpful?
0 / 5 - 0 ratings