Implementation of App.js rendering using `switch`
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 } from "react"; | |
import shortid from "shortid"; | |
import PushEvent from './components/PushEvent'; | |
import ReleaseEvent from './components/ReleaseEvent'; | |
import StatusEvent from './components/StatusEvent'; | |
import "./App.css"; | |
class IfApp extends Component { | |
render() { | |
const {events} = this.props; | |
const eventElement = events.map(event => { | |
switch (event) { | |
case "PushEvent": return <PushEvent key={shortid.generate()} />; | |
case "ReleaseEvent": return <ReleaseEvent key={shortid.generate()} />; | |
case "StatusEvent": return <StatusEvent key={shortid.generate()} />; | |
default: return <div key={shortid.generate()}></div>; | |
} | |
}); | |
return ( | |
<div> | |
{eventElement} | |
</div> | |
); | |
} | |
} | |
export default IfApp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment