diff --git a/src/Router.js b/src/Router.js index 50fc92a..76d06b4 100644 --- a/src/Router.js +++ b/src/Router.js @@ -1,5 +1,5 @@ import React from 'react'; -import { Route, Navigate, Routes, HashRouter } from 'react-router-dom'; +import { Route, Navigate, Routes, HashRouter as DOMRouter } from 'react-router-dom'; import Views from './views'; @@ -11,9 +11,9 @@ export default function Router(props) { const channelid = props.restreamer.GetCurrentChannelID(); return ( - + - } /> + } /> } /> } /> } /> @@ -26,7 +26,7 @@ export default function Router(props) { } /> } /> - + ); } diff --git a/src/views/ChannelSelect.js b/src/views/ChannelSelect.js index a268654..ba4b6d9 100644 --- a/src/views/ChannelSelect.js +++ b/src/views/ChannelSelect.js @@ -3,17 +3,24 @@ import { useNavigate } from 'react-router-dom'; export default function ChannelSelector(props) { const navigate = useNavigate(); + const [$channelid, setChannelid] = React.useState(''); React.useEffect(() => { onMount(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const onMount = () => { - const channelid = props.restreamer.GetCurrentChannelID(); + React.useEffect(() => { + navigate(`/${$channelid}`, { replace: true }); + }, [navigate, $channelid]); - navigate(`/${channelid}`, { replace: true }); + const onMount = () => { + setChannelid(props.channelid); }; return null; } + +ChannelSelector.defaultProps = { + channelid: '', +};