question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

custom renderToHtml function 'meta' parameter does not affect renderMeta prop passed to Document

See original GitHub issue

BUG: I was attempting to implement emotion-js following the styled-components example and have been unable to attach any data to the “meta” object and that data be available to the renderMeta prop passed to the Document

Environment

  1. react-static version: 5.9.7
  2. node version: 10.4.0
  3. npm version: 6.1.0
  4. Operating system: macOS High Sierra 10.13.5
  5. Browser and version (if relevant): n/a

Steps to Reproduce the problem

import { extractCritical } from 'emotion-server';
...
renderToHtml: (render, Comp, meta) => {
    const { html, ids, css } = extractCritical(render(<Comp/>));
    meta.css = css;
    meta.ids = ids;
    return html;
},
Document: class CustomHtml extends Component {
    render() {
          const {
              Html,
              Head,
              Body,
              children,
              renderMeta,
          } = this.props
          console.log("renderMeta: ", renderMeta);
          return (
              <Html>
                  <Head>
                      <meta charSet = "UTF-8" />
                      <meta name = "viewport" content = "width=device-width, initial-scale=1"/>
                  </Head>
                  <Body>
                      {children}
                  </Body>
              </Html>
          )
      }
 }

the console.log("renderMeta: ", renderMeta); logs an empty object. should that not be an object with the properties css and ids?

I’ve been unable to pass any value to the renderMeta object from the renderToHtml function when attaching properties to the 3rd meta parameter

https://react-static.js.org/docs/config#rendertohtml https://react-static.js.org/docs/config#document

Expected Behavior

any property attached to the “meta” object passed into renderToHtml should be available on the renderMeta prop passed to the custom Document in the config

Reproducible Demo

see code above

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tannerlinsleycommented, Jun 28, 2018

No it shouldn’t be necessary, since it’s embedding the styles directly into the html

On Wed, Jun 27, 2018 at 9:30 PM Michael Raumer notifications@github.com wrote:

well alright then, good enough for me. TBH i’ve been debating what the exact wording you circled actually means since I first read it because based on that I’m not entirely sure what the difference is b/w renderStylesToString and extractCritical is. The documentation sure does make it seem like extractCritical outputs a smaller subset of CSS.

in that case, is the {renderMeta.styleTags} necessary in Document since nothing is being attached to meta in the renderToHtml function?

thanks for being so responsive on this, I really do appreciate it

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/nozzle/react-static/issues/648#issuecomment-400899567, or mute the thread https://github.com/notifications/unsubscribe-auth/AFUmCa_QJt26tOCM7Ke3fPu68i-Zqj2uks5uBE3ggaJpZM4U6rxW .

1reaction
tannerlinsleycommented, Jun 28, 2018

Isn’t that what happens anyway? screen shot 2018-06-27 at 9 21 29 pm

Read more comments on GitHub >

github_iconTop Results From Across the Web

custom renderToHtml function 'meta' parameter does not affect ...
BUG: I was attempting to implement emotion-js following the ... 'meta' parameter does not affect renderMeta prop passed to Document #648.
Read more >
Props not being passed when using custom document for ...
js just has some styled components and a theme with a component that looks like this: class Page extends Component { render() {...
Read more >
react-static - npm
and `renderMeta` prop refers to any data you potentially assigned to it during. // the custom `renderToHtml` hook. Document: ({ Html, Head ...
Read more >
Displaying Data with Props - From JavaScript to React - Next.js
In your HomePage component, you can pass a custom title prop to the Header ... the child component, can accept those props as...
Read more >
https://raw.githubusercontent.com/nozzle/react-sta...
The entire internal state of React Static is now available via the `state` prop in the `Document` component - The `renderMeta` prop available...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found