CreatePage.jsx 758 B

1234567891011121314151617181920212223242526272829303132
  1. import React, { useEffect } from 'react';
  2. import PropTypes from 'prop-types';
  3. import { useCurrentPagePath } from '~/states/page';
  4. import { usePageCreateModalActions } from '~/states/ui/modal/page-create';
  5. const CreatePage = React.memo((props) => {
  6. const { open: openCreateModal } = usePageCreateModalActions();
  7. const currentPath = useCurrentPagePath();
  8. // setup effect
  9. useEffect(() => {
  10. openCreateModal(currentPath ?? '');
  11. // remove this
  12. props.onDeleteRender(this);
  13. }, [currentPath, openCreateModal, props]);
  14. return <></>;
  15. });
  16. CreatePage.propTypes = {
  17. onDeleteRender: PropTypes.func.isRequired,
  18. };
  19. CreatePage.getHotkeyStrokes = () => {
  20. return [['c']];
  21. };
  22. CreatePage.displayName = 'CreatePage';
  23. export default CreatePage;