React-static: state.siteData not available in dev

Created on 22 Apr 2019  路  3Comments  路  Source: react-static/react-static

Environment

    react: ^16.8.2 => 16.8.6 
    react-dom: ^16.8.2 => 16.8.6 
    react-static: ^7.0.0 => 7.0.9 
    react-static-plugin-reach-router: ^7.0.0 => 7.0.8 
    react-static-plugin-sitemap: ^7.0.0 => 7.0.8 
    react-static-plugin-source-filesystem: ^7.0.0 => 7.0.8 
    react-static-plugin-typescript: ^7.0.0 => 7.0.8 
    react-typography: ^0.16.19 => 0.16.19 

Steps to Reproduce the problem

  1. npx react-static create
  2. accept defaults
  3. yarn
  4. add following to static.config.json
  getSiteData: () => ({
    title: 'Hello, world',
  }),
  Document: ({ Html, Head, Body, children, state }) => {
    console.log(state.siteData)

    return (
      <Html lang="en-US">
      <Head></Head>
      <Body>{children}</Body>
      </Html>
    )
  }
  1. With yarn build, siteData is populated and the following is printed:
...
{ title: 'Hello, world' }
...
  1. With yarn dev, siteData is undefined and nothing is printed.

Expected Behavior

siteData would also be available in dev stage.

Related: https://github.com/nozzle/react-static/issues/1102

bug help wanted

Most helpful comment

Good find. We'll work on an update for this asap.

All 3 comments

Good find. We'll work on an update for this asap.

:+1:

(Off-topic: please note that I couldn't re-open #1144 as you requested due to permissions.)

I need this as well. Any status?

Was this page helpful?
0 / 5 - 0 ratings