Skip to content

Instantly share code, notes, and snippets.

@vnglst
Last active February 15, 2016 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vnglst/519f151454a037d1184b to your computer and use it in GitHub Desktop.
Save vnglst/519f151454a037d1184b to your computer and use it in GitHub Desktop.
React examples
// React stateless components examples
// Example based on egghead.io lesson 14
// https://egghead.io/lessons/react-building-stateless-function-components-new-in-react-0-14
// Stateless component definition as function
const UserList = ({users}) => (
<div>
{users.map(user => {
return <div>{user.name} - {user.type)</div>
})}
</div>
);
// Adding prop types
import React, { PropTypes } from 'react';
UserList.propTypes = {
users: React.PropTypes.arrayOf(React.PropTypes.object).isRequired
};
// Exporting as module
export default UserList;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment