mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 17:15:48 +00:00
homePath removed from Router
This commit is contained in:
parent
10a804ff24
commit
1226b0086d
1 changed files with 1 additions and 20 deletions
|
|
@ -10,28 +10,10 @@ const routeConfigForPath = require('./routeConfigForPath');
|
|||
const urlParamsForPath = require('./urlParamsForPath');
|
||||
|
||||
const Router = ({ className, onPathNotMatch, ...props }) => {
|
||||
const { homePath, viewsConfig } = React.useMemo(() => ({
|
||||
homePath: props.homePath,
|
||||
viewsConfig: props.viewsConfig
|
||||
}), []);
|
||||
const viewsConfig = React.useMemo(() => props.viewsConfig, []);
|
||||
const [views, setViews] = React.useState(() => {
|
||||
return Array(viewsConfig.length).fill(null);
|
||||
});
|
||||
React.useLayoutEffect(() => {
|
||||
if (typeof homePath === 'string') {
|
||||
const { pathname, path } = UrlUtils.parse(window.location.hash.slice(1));
|
||||
if (homePath !== path) {
|
||||
window.location.replace(`#${homePath}`);
|
||||
const routeConfig = typeof pathname === 'string' ?
|
||||
routeConfigForPath(viewsConfig, pathname)
|
||||
:
|
||||
null;
|
||||
if (routeConfig) {
|
||||
window.location = `#${path}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
React.useLayoutEffect(() => {
|
||||
const onLocationHashChange = () => {
|
||||
const { pathname, query } = UrlUtils.parse(window.location.hash.slice(1));
|
||||
|
|
@ -111,7 +93,6 @@ const Router = ({ className, onPathNotMatch, ...props }) => {
|
|||
|
||||
Router.propTypes = {
|
||||
className: PropTypes.string,
|
||||
homePath: PropTypes.string,
|
||||
onPathNotMatch: PropTypes.func,
|
||||
viewsConfig: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.exact({
|
||||
regexp: PropTypes.instanceOf(RegExp).isRequired,
|
||||
|
|
|
|||
Loading…
Reference in a new issue