mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 07:32:02 +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 urlParamsForPath = require('./urlParamsForPath');
|
||||||
|
|
||||||
const Router = ({ className, onPathNotMatch, ...props }) => {
|
const Router = ({ className, onPathNotMatch, ...props }) => {
|
||||||
const { homePath, viewsConfig } = React.useMemo(() => ({
|
const viewsConfig = React.useMemo(() => props.viewsConfig, []);
|
||||||
homePath: props.homePath,
|
|
||||||
viewsConfig: props.viewsConfig
|
|
||||||
}), []);
|
|
||||||
const [views, setViews] = React.useState(() => {
|
const [views, setViews] = React.useState(() => {
|
||||||
return Array(viewsConfig.length).fill(null);
|
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(() => {
|
React.useLayoutEffect(() => {
|
||||||
const onLocationHashChange = () => {
|
const onLocationHashChange = () => {
|
||||||
const { pathname, query } = UrlUtils.parse(window.location.hash.slice(1));
|
const { pathname, query } = UrlUtils.parse(window.location.hash.slice(1));
|
||||||
|
|
@ -111,7 +93,6 @@ const Router = ({ className, onPathNotMatch, ...props }) => {
|
||||||
|
|
||||||
Router.propTypes = {
|
Router.propTypes = {
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
homePath: PropTypes.string,
|
|
||||||
onPathNotMatch: PropTypes.func,
|
onPathNotMatch: PropTypes.func,
|
||||||
viewsConfig: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.exact({
|
viewsConfig: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.exact({
|
||||||
regexp: PropTypes.instanceOf(RegExp).isRequired,
|
regexp: PropTypes.instanceOf(RegExp).isRequired,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue