> | string | number | {} | React.ReactNodeArray | React.ReactPortal | boolean | null | undefined {
return (
{this.state.messages.map(this.renderMessage)}
)
}
renderMessage(message: XChatMessage) {
return (
{message.from}:
{message.text}
)
}
scrollToBottom() {
const wrapper = this.wrapper.current;
wrapper.scrollTop = wrapper.scrollHeight
}
componentDidUpdate(): void {
this.scrollToBottom();
}
componentDidMount(): void {
this.scrollToBottom();
this.unsubscribe = subscribeWithSelector(
xChatStateSelector,
() => {
this.setState(
getState(),
)
}
)
}
componentWillUnmount(): void {
this.unsubscribe()
}
}
const Wrapper = styled.div`
width: auto;
max-width: 400px;
border: 1px solid #eee;
height: 450px;
padding: 10px;
box-sizing: border-box;
overflow: auto;
`;
const Message = styled.div`
border-radius: 30px;
background-color: aliceblue;
padding: 10px 20px;
display: inline-block;
line-height: 1em;
text-align: left;
margin: 5px 0;
`;
const Title = styled.p`
margin: 0;
`;