Fix ChannelSelect routing
This commit is contained in:
parent
3a5a91c2c9
commit
4ec02d1b2d
@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
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';
|
import Views from './views';
|
||||||
|
|
||||||
@ -11,9 +11,9 @@ export default function Router(props) {
|
|||||||
const channelid = props.restreamer.GetCurrentChannelID();
|
const channelid = props.restreamer.GetCurrentChannelID();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HashRouter>
|
<DOMRouter>
|
||||||
<Routes>
|
<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="/playersite" element={<Views.Playersite restreamer={props.restreamer} />} />
|
||||||
<Route path="/settings" element={<Views.Settings restreamer={props.restreamer} />} />
|
<Route path="/settings" element={<Views.Settings restreamer={props.restreamer} />} />
|
||||||
<Route path="/settings/:tab" 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="/:channelid/publication/:service/:index" element={<Views.EditService key={channelid} restreamer={props.restreamer} />} />
|
||||||
<Route path="*" render={() => <Navigate to="/" replace />} />
|
<Route path="*" render={() => <Navigate to="/" replace />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</HashRouter>
|
</DOMRouter>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,17 +3,24 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
|
|
||||||
export default function ChannelSelector(props) {
|
export default function ChannelSelector(props) {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const [$channelid, setChannelid] = React.useState('');
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
onMount();
|
onMount();
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onMount = () => {
|
React.useEffect(() => {
|
||||||
const channelid = props.restreamer.GetCurrentChannelID();
|
navigate(`/${$channelid}`, { replace: true });
|
||||||
|
}, [navigate, $channelid]);
|
||||||
|
|
||||||
navigate(`/${channelid}`, { replace: true });
|
const onMount = () => {
|
||||||
|
setChannelid(props.channelid);
|
||||||
};
|
};
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChannelSelector.defaultProps = {
|
||||||
|
channelid: '',
|
||||||
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user