Skip to content

Instantly share code, notes, and snippets.

@ronit-mukherjee
Created June 16, 2018 02:00
Show Gist options
  • Save ronit-mukherjee/d581aaaf8538d799f32360d958f60c01 to your computer and use it in GitHub Desktop.
Save ronit-mukherjee/d581aaaf8538d799f32360d958f60c01 to your computer and use it in GitHub Desktop.
React HOC - Wrap any of your page level contents in this wrapper to exclude the use of additional div as parent component required by react render, secondly this wrapper component helps to set page level seo meta tags like title, description, keywords buy just passing these in props to it
import React from 'react'
import {Helmet} from 'react-helmet'
export default (props) => (
<div id={props.id?props.id:""}>
{
props.title ||
props.description ||
props.keywords ?
<Helmet>
{props.title ? <title>{props.title}</title> : null}
{
props.description ? <meta name="description"
content={props.description}/>:null
}
{
props.keywords ?
<meta name="keywords"
content={props.keywords}/> : null
}
</Helmet> : null
}
{props.children}
</div>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment