mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-28 17:57:48 +02:00
33 lines
914 B
TypeScript
33 lines
914 B
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
import {useEffect, type ReactNode} from 'react';
|
|
import {useHistory} from '@docusaurus/router';
|
|
import Layout from '@theme/Layout';
|
|
import Heading from '@theme/Heading';
|
|
|
|
// Test for https://github.com/facebook/docusaurus/issues/10988
|
|
function BlockNavigation() {
|
|
const history = useHistory();
|
|
useEffect(() => {
|
|
return history.block(() => {
|
|
// eslint-disable-next-line no-alert
|
|
alert('navigation blocked successfully');
|
|
return false;
|
|
});
|
|
}, [history]);
|
|
return false;
|
|
}
|
|
|
|
export default function HistoryTestsPage(): ReactNode {
|
|
return (
|
|
<Layout>
|
|
<Heading as="h1">History tests</Heading>
|
|
<p>This page should block navigation</p>
|
|
<BlockNavigation />
|
|
</Layout>
|
|
);
|
|
}
|