js-waku/web-chat/src/App.tsx

42 lines
759 B
TypeScript
Raw Normal View History

2021-04-14 04:44:12 +00:00
import React from 'react';
import './App.css';
2021-04-16 01:32:00 +00:00
import Room from './Room';
2021-04-19 00:36:37 +00:00
import WakuMock from './WakuMock';
2021-04-14 04:44:12 +00:00
2021-04-14 05:23:00 +00:00
interface Props {
}
interface State {
messages: string[]
}
class App extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
2021-04-19 00:36:37 +00:00
messages: []
2021-04-14 05:23:00 +00:00
};
2021-04-19 00:36:37 +00:00
WakuMock.create().then((wakuMock) => {
wakuMock.on('message',(message)=>{
const messages = this.state.messages.slice();
messages.push(message.message);
this.setState({messages});
})
});
2021-04-14 05:23:00 +00:00
}
render() {
return (
<div className='App'>
2021-04-16 01:32:00 +00:00
<div className='chat-room'>
<Room lines={this.state.messages} />
2021-04-14 05:23:00 +00:00
</div>
2021-04-14 05:13:55 +00:00
</div>
2021-04-14 05:23:00 +00:00
);
}
2021-04-14 04:44:12 +00:00
}
export default App;