Skip to content

Instantly share code, notes, and snippets.

@StevenLangbroek
Created January 4, 2016 14:12
Show Gist options
  • Save StevenLangbroek/431879d362fbdc863cba to your computer and use it in GitHub Desktop.
Save StevenLangbroek/431879d362fbdc863cba to your computer and use it in GitHub Desktop.
Naive Pure Component
import React from 'react';
export default (render) => class extends React.Component {
shouldComponentUpdate(nextProps, nextState){
return nextProps !== this.props;
}
render(){
return render(this.props);
}
}
import c from './pureComponent';
const ListItem = c(({
title,
description
}) => (
<li>
<h2>{title}</h2>
<p>{description}</p>
</li>
));
export default c(({
listItems
}) => (
<div>
<ul>{listItems.map(i => <ListItem {...i} />)}</ul>
</div>
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment