Timeline.js

 1import { withStyles } from '@material-ui/core/styles'
 2import React from 'react'
 3import Message from './Message'
 4
 5const styles = theme => ({
 6  main: {
 7    '& > *:not(:last-child)': {
 8      marginBottom: 10
 9    }
10  }
11})
12
13class Timeline extends React.Component {
14
15  props: {
16    ops: Array,
17    fetchMore: (any) => any,
18    classes: any,
19  }
20
21  render() {
22    const {ops, classes} = this.props
23
24    return (
25      <div className={classes.main}>
26        { ops.map((op, index) => {
27          switch (op.__typename) {
28            case 'CreateOperation':
29              return <Message key={index} message={op}/>
30            case 'AddCommentOperation':
31              return <Message key={index} message={op}/>
32
33            default:
34              console.log('unsupported operation type ' + op.__typename)
35              return null
36          }
37        })}
38      </div>
39    )
40  }
41}
42
43export default withStyles(styles)(Timeline)