fixed navigation links
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user