Fix ChannelSelect routing
This commit is contained in:
parent
3a5a91c2c9
commit
4ec02d1b2d
@ -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 (
|
||||
<HashRouter>
|
||||
<DOMRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<Views.ChannelSelect restreamer={props.restreamer} />} />
|
||||
<Route path="/" element={<Views.ChannelSelect channelid={channelid} />} />
|
||||
<Route path="/playersite" element={<Views.Playersite restreamer={props.restreamer} />} />
|
||||
<Route path="/settings" element={<Views.Settings restreamer={props.restreamer} />} />
|
||||
<Route path="/settings/:tab" element={<Views.Settings restreamer={props.restreamer} />} />
|
||||
@ -26,7 +26,7 @@ export default function Router(props) {
|
||||
<Route path="/:channelid/publication/:service/:index" element={<Views.EditService key={channelid} restreamer={props.restreamer} />} />
|
||||
<Route path="*" render={() => <Navigate to="/" replace />} />
|
||||
</Routes>
|
||||
</HashRouter>
|
||||
</DOMRouter>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -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: '',
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user