Created
June 16, 2018 02:00
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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