Giter Site home page Giter Site logo

react-head-tags's Introduction

react-head-tags

ReactDOMServer.renderToNodeStream() ready component to manage document.head

Installation

npm install react-head-tags --save

Usage

import React from 'react'
import { renderToNodeStream } from 'react-dom/server'
import { HeadManager, HeadTags } from 'react-head-tags'

let headTags
const contentStream = renderToNodeStream(
  <HeadManager
    onHeadTagsChange={tags => {
      headTags = tags
    }}
  >
    <HeadTags>
      <title>Title</title>
      <meta name="description" content="testing" />
    </HeadTags>
  </HeadManager>,
)

Note that head tags are not collected before the app is rendered, e.g. headTags is undefined until contentStream is finished in the above example.

react-head-tags's People

Contributors

ratson avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-head-tags's Issues

SSR example

Hi, thanks for the library!

I tried to use it with SSR renderToNodeStream function, but it doesn't work as expected. I got html without tags and they coming only after client render.

As far as I know, until we call stream.pipe(res, { end: false }) nothing is rendered, so no meta info is received. But when we start piping, we cant modify head. Is that correct?

In tests, I see, that you use streamToPromise. Why? Is it required, so HeadManager would be able to collect all tags?

Where is this mains.js file in repo?

in file src/server.js
line4: const ssr = require("./ssr/mains.js");

I could not find this file (mains.js) in repo (master branch). Could not understand how it is working?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.