EditPage.jsx 898 B

123456789101112131415161718192021222324252627282930313233343536
  1. import React, { useEffect } from 'react';
  2. import PropTypes from 'prop-types';
  3. import NavigationContainer from '../../../services/NavigationContainer';
  4. import { withUnstatedContainers } from '../../UnstatedUtils';
  5. const EditPage = (props) => {
  6. // setup effect
  7. useEffect(() => {
  8. // ignore when dom that has 'modal in' classes exists
  9. if (document.getElementsByClassName('modal in').length > 0) {
  10. return;
  11. }
  12. props.navigationContainer.setEditorMode('edit');
  13. // remove this
  14. props.onDeleteRender(this);
  15. }, [props]);
  16. return <></>;
  17. };
  18. EditPage.propTypes = {
  19. navigationContainer: PropTypes.instanceOf(NavigationContainer).isRequired,
  20. onDeleteRender: PropTypes.func.isRequired,
  21. };
  22. const EditPageWrapper = withUnstatedContainers(EditPage, [NavigationContainer]);
  23. EditPageWrapper.getHotkeyStrokes = () => {
  24. return [['e']];
  25. };
  26. export default EditPageWrapper;