diff --git a/web-chat/src/App.tsx b/web-chat/src/App.tsx index 32a7e3618d..7f09b2b4bb 100644 --- a/web-chat/src/App.tsx +++ b/web-chat/src/App.tsx @@ -2,14 +2,31 @@ import React from 'react'; import './App.css'; import Log from './Log'; -function App() { - return ( -
-
- +interface Props { +} + +interface State { + messages: string[] +} + +class App extends React.Component { + constructor(props: Props) { + super(props); + + this.state = { + messages: ['Here is a line', 'Here is another line'] + }; + } + + render() { + return ( +
+
+ +
-
- ); + ); + } } export default App; diff --git a/web-chat/src/Log.tsx b/web-chat/src/Log.tsx index 765b8f57a3..cead27f6f9 100644 --- a/web-chat/src/Log.tsx +++ b/web-chat/src/Log.tsx @@ -1,40 +1,31 @@ import React from 'react'; interface Props { + lines: string[] } interface State { - lines: string[]; } export default class Log extends React.Component { - state: State = { - lines: [ - 'here', - 'is', - 'a', - 'line' - ] - }; - render() { return (
- {this.renderLines()} + {this.renderLines(this.props.lines)}
); } - renderLines() { + renderLines(lines: string[]) { - const lines = []; - for (const line of this.state.lines) { - lines.push(
{line}
); + const renderedLines = []; + for (const line of lines) { + renderedLines.push(
{line}
); } return (
- {lines} + {renderedLines}
); }