document.body.removeChild(tmp);
}
-function GameInfo(props) {
+const GameInfo = React.memo(props => {
if (! props.id)
return null;
>Copy Link</button>
</div>
);
-}
+});
-function PlayerInfo(props) {
+const PlayerInfo = React.memo(props => {
if (! props.player.id)
return null;
))}
</div>
);
-}
+});
function fetch_method_json(method, api = '', data = {}) {
const response = fetch(api, {
return fetch_method_json('PUT', api, data);
}
-class CategoryRequest extends React.Component {
+class CategoryRequest extends React.PureComponent {
constructor(props) {
super(props);
this.category = React.createRef();
}
}
-function PromptOptions(props) {
+const PromptOptions = React.memo(props => {
function handle_click(id) {
fetch_post_json(`vote/${id}`);
onClick={() => handle_click(p.id)}
>
{p.prompt}
+ <div className="vote-choices">
+ {p.votes.map(v => {
+ return (
+ <div
+ key={v}
+ className="vote-choice"
+ >
+ {v}
+ </div>
+ );
+ })}
+ </div>
</button>
);
})}
</div>
);
-}
+});
-class Game extends React.Component {
+class Game extends React.PureComponent {
constructor(props) {
super(props);
this.state = {