Skip to content

Instantly share code, notes, and snippets.

@frenzzy
Created September 7, 2016 12:35
Show Gist options
  • Save frenzzy/421b9e608b0936a67bee381cd429c90e to your computer and use it in GitHub Desktop.
Save frenzzy/421b9e608b0936a67bee381cd429c90e to your computer and use it in GitHub Desktop.
RSK context.setMeta example
/**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React, { PropTypes } from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Home.css';
const title = 'React Starter Kit';
function Home({ news }, context) {
context.setTitle(title);
context.setMeta('description', 'Home Page Description');
return (
<div className={s.root}>
<div className={s.container}>
<h1 className={s.title}>React.js News</h1>
<ul className={s.news}>
{news.map((item, index) => (
<li key={index} className={s.newsItem}>
<a href={item.link} className={s.newsTitle}>{item.title}</a>
<span
className={s.newsDesc}
dangerouslySetInnerHTML={{ __html: item.contentSnippet }}
/>
</li>
))}
</ul>
</div>
</div>
);
}
Home.propTypes = {
news: PropTypes.arrayOf(PropTypes.shape({
title: PropTypes.string.isRequired,
link: PropTypes.string.isRequired,
contentSnippet: PropTypes.string,
})).isRequired,
};
Home.contextTypes = {
setTitle: PropTypes.func.isRequired,
setMeta: PropTypes.func.isRequired,
};
export default withStyles(s)(Home);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment