Created
October 21, 2016 20:49
-
-
Save bnhansn/e7d4700d68226716a136d4d36b39366e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| type Props = { | |
| room: { | |
| id: number, | |
| name: string, | |
| }, | |
| currentUserRoomIds: Array, | |
| onRoomJoin: () => void, | |
| } | |
| const RoomListItem = ({ room, currentUserRoomIds, onRoomJoin }: Props) => { | |
| const isJoined = currentUserRoomIds.includes(room.id); | |
| return ( | |
| <div key={room.id} style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '10px' }}> | |
| <span style={{ marginRight: '8px' }}>{room.name}</span> | |
| <button | |
| onClick={() => onRoomJoin(room.id)} | |
| className="btn btn-sm" | |
| disabled={isJoined} | |
| > | |
| {isJoined ? 'Joined' : 'Join'} | |
| </button> | |
| </div> | |
| ); | |
| }; | |
| export default RoomListItem; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment