2

We can see JsonLd information in client side rendering. When we render through server, the information is not available because of rendering and then fetching data (through API).

we have tried the following but nothing works:

  1. fetch data in parent, pass the data to child and then render child method
render () {
if (!data) {
return (<div> Loading... </div>);
} else {
<childComponent />  }
  1. render loader if data not fetched yet
render () {   if (!data) {
return (<div> Loading... </div>);   } else {
 <div>
    <script> {jsonld_data} </script>
  </div>    }  }
  1. ReactDOM.hydrate
ReactDOM.hydrate( <AppContainer> <HotRootContainer store={store}
history={history} /> </AppContainer>, rootEl );

The json-ld data on render function

<Helmet>
<script type="application/ld+json">
{JSON.stringify(this.structuredData)}
</script>
</Helmet>

What we are missing here?

M.R
  • 610
  • 2
  • 10
  • 34

0 Answers0