fixed navigation links

This commit is contained in:
2023-04-07 11:17:50 +02:00
parent 2eb05585f1
commit 10ccc2ee7c
3 changed files with 12 additions and 13 deletions

View File

@@ -1,11 +1,13 @@
import useTitle from "../../utils/hooks/TitleHook";
import React from "react";
import {useNavigate} from "react-router";
const ROOM_URL = `http://${process.env.REACT_APP_API_URL}/room`;
const Rooms = () => {
useTitle('Mau-Mau Rooms');
const navigateTo = useNavigate();
const [rooms, setRooms] = React.useState<string[]>([]);
@@ -15,10 +17,6 @@ const Rooms = () => {
.then(data => setRooms(data));
}, []);
const gotoRoom = (room: string) => {
window.location.host = `/room/${room}`;
}
return (
<div>
<h1>Rooms</h1>
@@ -26,7 +24,7 @@ const Rooms = () => {
{
rooms.map((room, index) => {
return <li key={index} className={"clickable"}
onClick={() => gotoRoom(room)}>{room}</li>
onClick={() => navigateTo(`/room/${room}`)}>{room}</li>
})
}
</ul>