airbnb / hypernova-react

React bindings for Hypernova.
https://github.com/airbnb/hypernova
MIT License
248 stars 43 forks source link

renderReact not works #43

Closed k4mr4n closed 6 years ago

k4mr4n commented 6 years ago

Hey all

<div id="root">{{ html }}</div>

If hypernova server fails by any reason and the html content would be empty, then the renderReact('Component', Component) wouldn't work either returns blank page and I have to call:

ReactDOM.hydrate(
    <Component />,
    document.getElementById('root')
  )

In this case how could I know my root is empty? because this condition throws error due to undefined document object: document.getElementById('root') !== null && document.getElementById('root').hasChildNodes()

TypeError: ((!(null === document.getElementById(...))) && document.getElementById(...).hasChildNodes(...)) is not a function
ljharb commented 6 years ago

This seems like a duplicate of https://github.com/airbnb/hypernova/issues/115

k4mr4n commented 6 years ago

@ljharb yes no one there answered and I thought its concern with this repo too so I clone it here! and what do you think about it?

k4mr4n commented 6 years ago

@ljharb I fixed it with if-else in my code that's why I closed it and in the first place my if-else had a syntax problem that's why I was getting TypeError 😞

ljharb commented 6 years ago

Thanks for clarifying :-)

kstratis commented 4 years ago

My apologies for resurrecting the dead but why would someone have to manually check whether the server failed to render or not..?

reactRender should have been able to figure that out from the data keys... right?