Created
January 4, 2016 14:12
-
-
Save StevenLangbroek/431879d362fbdc863cba to your computer and use it in GitHub Desktop.
Naive Pure Component
This file contains hidden or 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'; | |
export default (render) => class extends React.Component { | |
shouldComponentUpdate(nextProps, nextState){ | |
return nextProps !== this.props; | |
} | |
render(){ | |
return render(this.props); | |
} | |
} |
This file contains hidden or 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 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