Merge pull request #5295 from storybooks/fix/file-system-host

FIX issue where storybook wouldn't be able to navigate when hosted as a file://
This commit is contained in:
Norbert de Langen 2019-01-19 12:32:16 +01:00 committed by GitHub
commit b5cba23d12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,13 +55,15 @@ interface QueryLinkProps {
children: React.ReactNode;
}
const base = document.location.pathname + '?';
const queryNavigate = (to: string) => {
navigate(`?path=${to}`);
navigate(`${base}path=${to}`);
};
// A component that will navigate to a new location/path when clicked
const QueryLink = ({ to, children, ...rest }: QueryLinkProps) => (
<Link to={`?path=${to}`} {...rest}>
<Link to={`${base}path=${to}`} {...rest}>
{children}
</Link>
);