Skip to content

Instantly share code, notes, and snippets.

@cserrano3
Last active September 23, 2018 03:41
Show Gist options
  • Select an option

  • Save cserrano3/3a8eed88e65cdf2098c3697a346ae960 to your computer and use it in GitHub Desktop.

Select an option

Save cserrano3/3a8eed88e65cdf2098c3697a346ae960 to your computer and use it in GitHub Desktop.

Revisions

  1. cserrano3 revised this gist Sep 23, 2018. No changes.
  2. cserrano3 created this gist Sep 23, 2018.
    13 changes: 13 additions & 0 deletions App.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    const App = () => {
    <List
    render={
    ({items}) => (
    <ul>
    {items.map(item => {
    <li key={item.id}>{item.name}</li>
    })}
    </ul>
    )
    }
    />
    };
    16 changes: 16 additions & 0 deletions List.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    export default class List extends React.Component {
    constructor(props) {
    super(props);
    this.state = {
    items: []
    };
    }

    componentDidMount() {
    this.setState({items: source.getItems()});
    }

    render() {
    return this.props.render(this.state);
    }
    }