Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Created October 21, 2016 20:49
Show Gist options
  • Save bnhansn/e7d4700d68226716a136d4d36b39366e to your computer and use it in GitHub Desktop.
Save bnhansn/e7d4700d68226716a136d4d36b39366e to your computer and use it in GitHub Desktop.
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