Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR: Using example code in README, helmetContext.helmet has blank properies no matter what's defined #118

Open
j-rp opened this issue Feb 9, 2021 · 5 comments

Comments

@j-rp
Copy link

j-rp commented Feb 9, 2021

When using a markup with

const App = <HelmetProvider context={helmetContext}>
                       etc. etc.
                    </HelmetProvider>

with a component that contains

<Helmet>
                <title>
                    My title
                </title>
                <meta
                    name="twitter:card"
                    content="See here"
                />
lots more properties
            </Helmet>

in it,

and after a

const myRenderedApp = renderToString(App);
console.log(JSON.stringify(helmetContext));

I get:

{"helmet":{"base":{},"bodyAttributes":{},"htmlAttributes":{},"link":{},"meta":{},"noscript":{},"script":{},"style":{},"title":{}}}

the component itself renders just fine (html produced, etc.) but with no discernable tags set from Helmet.

I was kind of expecting both the meta tags and the title to be filled out there.

@j-rp j-rp changed the title Using example code in README, helmet is always empty no matter what's defined Using example code in README, helmetContext.helmet has blank properies no matter what's defined Feb 9, 2021
@j-rp j-rp changed the title Using example code in README, helmetContext.helmet has blank properies no matter what's defined SSR: Using example code in README, helmetContext.helmet has blank properies no matter what's defined Feb 9, 2021
@hAppywAy
Copy link

same here. Did you find any solution?

@hAppywAy
Copy link

hAppywAy commented Feb 23, 2021

same here. Did you find any solution?

Finally I've understood my issue. In Helmet component, direct child was a fragment and not any meta tags. Once I ve removed it this was working.

@sanpanthera
Copy link

sanpanthera commented Feb 23, 2021

@hAppywAy Is your application SSR based? If yes can you please confirm all meta tags are appearing in page view source (not in inspect element developer tools)

@hAppywAy
Copy link

@sanpanthera yes it is

@j-rp
Copy link
Author

j-rp commented Feb 23, 2021

@hAppywAy for what it’s worth, we moved to react-meta-tags, which worked well in SSR immediately and has the bonus of being actively maintained. :). I’m going to leave this issue open so that if anyone else is wrestling with helmet’s SSR that they can also be pointed to a good alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants