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

Meta headtags don't generate anything on SSR #43

Open
calculuschild opened this issue May 19, 2020 · 0 comments
Open

Meta headtags don't generate anything on SSR #43

calculuschild opened this issue May 19, 2020 · 0 comments

Comments

@calculuschild
Copy link

I'm not sure why the headtags are restricted to do anything "onServer", but I haven't found a good way to make them actually generate header tags except for the Title which directly edits the DOM.

Title({ children }){
	if(onServer) NamedTags.title = `<title>${children.join('')}</title>`;
	React.useEffect(()=>{document.title = children.join('')}, [children]); <====
	return null;
},

Might I suggest removing the "onServer" check and adding an Event listener? Otherwise all of the updated props seem to get overwritten on Hydration.

Meta(props) {
  let tag = `<meta ${obj2props(props)} />`;
  props.property || props.name ? NamedTags[props.property || props.name] = tag : UnnamedTags.push(tag);

  React.useEffect(() => {
    document.getElementsByTagName('head')[0].insertAdjacentHTML('beforeend', Object.values(NamedTags).join('\n'));
  },[NamedTags]);
  return null;
},

Otherwise if headtags could be added to the pack output so we can insert them into our template function.

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

1 participant