React Page Context
A higher-order React component that allows to set document's title, description and other meta tags, as well as
<link>
and<script>
tags from inside regular React components viacontext.page
context variable.
See the changelog for past and future (planned) changes to the project | Join #react-starter-git on Gitter to stay up to date
How to Install
$ npm install page-context --save
Getting Started
- Import
PageContext
types frompage-context
npm module - Add
contextTypes
static property to your React component that needs access todocument.title
and other<head>
elements - Use
context.page
function to manipulate document's<head>
section
Here is an example:
components/HomePage.js
; { ; return <div> <h1>Welcome!</h1> <p>This is my personal home page</p> </div> ;} HomePagecontextTypes = page: PropTypesfuncisRequired ; ;
main.js
;;;; ReactDOM;
Server-side Rendering Example
server.js
;;;; const app = ; app; app;
Backers
♥ React Page Context? Help us keep it alive by donating funds to cover project expenses via Patreon or PayPal!
Related Projects
- React Starter Kit — Isomorphic web app boilerplate (Node.js/Express, React.js, GraphQL)
- Babel Starter Kit — JavaScript library boilerplate (ES2015+, Babel)
Get in Touch
- #react-starter-kit on Gitter
- @koistya on Codementor
License
Copyright © 2016 Kriasoft, LLC. This source code is licensed under the MIT license found in the LICENSE.txt file. The documentation to the project is licensed under the CC BY-SA 4.0 license.
Made with ♥ by Konstantin Tarkus (@koistya) and contributors