mirror of https://github.com/waku-org/js-waku.git
Makes lines a functional component
This commit is contained in:
parent
50a2c3777b
commit
7921aa5427
|
@ -3,7 +3,7 @@ import {
|
||||||
Grid,
|
Grid,
|
||||||
List,
|
List,
|
||||||
ListItem,
|
ListItem,
|
||||||
ListItemText, Paper
|
ListItemText
|
||||||
} from '@material-ui/core';
|
} from '@material-ui/core';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import MessageInput from './MessageInput';
|
import MessageInput from './MessageInput';
|
||||||
|
@ -37,12 +37,12 @@ export default class Room extends React.Component<Props, State> {
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Box height={1080} maxHeight={1080}
|
<Box height={1080} maxHeight={1080}
|
||||||
style={{ flex: 1, maxHeight: '100%', overflow: 'scroll' }}>
|
style={{ flex: 1, maxHeight: '100%', overflow: 'scroll' }}>
|
||||||
{this.renderLines()}
|
<Lines messages={this.props.lines} />
|
||||||
</Box>
|
</Box>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Grid container spacing={2} direction="row" alignItems="center">
|
<Grid container spacing={2} direction='row' alignItems='center'>
|
||||||
<Grid item xs={11}>
|
<Grid item xs={11}>
|
||||||
<MessageInput messageHandler={this.messageHandler.bind(this)} />
|
<MessageInput messageHandler={this.messageHandler.bind(this)} />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -55,12 +55,16 @@ export default class Room extends React.Component<Props, State> {
|
||||||
</Grid>
|
</Grid>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Make it own component
|
interface LinesProps {
|
||||||
renderLines() {
|
messages: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
const Lines = (props: LinesProps) => {
|
||||||
const renderedLines = [];
|
const renderedLines = [];
|
||||||
|
|
||||||
for (const line of this.props.lines) {
|
for (const line of props.messages) {
|
||||||
renderedLines.push(<ListItem>
|
renderedLines.push(<ListItem>
|
||||||
<ListItemText
|
<ListItemText
|
||||||
primary={line}
|
primary={line}
|
||||||
|
@ -73,5 +77,4 @@ export default class Room extends React.Component<Props, State> {
|
||||||
{renderedLines}
|
{renderedLines}
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue