Guest User

Untitled

a guest
Nov 18th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import React, {Component} from 'react'
  2.  
  3. function ImgTag({imgLink}){
  4. return imgLink && (<div className="message-img"><img src={imgLink} alt="An image in the chat"/></div>);
  5. }
  6.  
  7. function Message({msg}){
  8. return (
  9. <div className="message">
  10. <span className={`message-username ${msg.color}`}>{ msg.username }</span>
  11. <span className="message-content">
  12. { msg.content }
  13. { this.imgTag(msg.imgUrl) }
  14. </span>
  15. </div>
  16. )
  17.  
  18. }
  19.  
  20. function Messages({msgData}){
  21. const msgs = msgData.map((msg) => (msg.type === 'message' ? <Message key={msg.uuid} msg={msg}/> : <div key={msg.uuid} className="message system">
  22. { msg.content }
  23. </div>));
  24.  
  25. return (
  26. <section id="message">{ msgs }</section>
  27. )
  28.  
  29. }
  30.  
  31. export default Messages
Add Comment
Please, Sign In to add comment