Created
October 28, 2018 16:30
-
-
Save dance2die/e6497b267559a71745b86940da620037 to your computer and use it in GitHub Desktop.
This file contains 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, { Component, Suspense } from "react"; | |
import shortid from "shortid"; | |
import * as Events from "./events"; | |
import "./App.css"; | |
class App extends Component { | |
render() { | |
const { events } = this.props; | |
const components = events.map(event => { | |
const Component = Events[event.type]; | |
const key = shortid.generate(); | |
return Component ? ( | |
<Component key={key} {...event} /> | |
) : ( | |
<Events.NullEvent key={key} /> | |
); | |
}); | |
return ( | |
<Suspense fallback={<div>Loading...</div>}> | |
<h2>Sung''s GitHub Events</h2> | |
<div>{components}</div> | |
</Suspense> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment