Skip to content

Commit

Permalink
fix: warning: The prop onClose marked as required in SelectTypeModal
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald committed Sep 14, 2024
1 parent b29f255 commit fde5200
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 36 deletions.
42 changes: 16 additions & 26 deletions src/editors/Editor.jsx → src/editors/Editor.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import React from 'react';
import { useDispatch } from 'react-redux';
import PropTypes from 'prop-types';
import { FormattedMessage } from '@edx/frontend-platform/i18n';

import messages from './messages';
import * as hooks from './hooks';

import supportedEditors from './supportedEditors';
import type { EditorComponent } from './EditorComponent';

const Editor = ({
learningContextId,
export interface Props extends EditorComponent {
blockType: string;
blockId?: string | null;
learningContextId?: string | null;
lmsEndpointUrl?: string | null;
studioEndpointUrl?: string | null;
}

const Editor: React.FC<Props> = ({
learningContextId = null,
blockType,
blockId,
lmsEndpointUrl,
studioEndpointUrl,
onClose,
returnFunction,
blockId = null,
lmsEndpointUrl = null,
studioEndpointUrl = null,
onClose = null,
returnFunction = null,
}) => {
const dispatch = useDispatch();
hooks.initializeApp({
Expand Down Expand Up @@ -46,23 +54,5 @@ const Editor = ({
</div>
);
};
Editor.defaultProps = {
blockId: null,
learningContextId: null,
lmsEndpointUrl: null,
onClose: null,
returnFunction: null,
studioEndpointUrl: null,
};

Editor.propTypes = {
blockId: PropTypes.string,
blockType: PropTypes.string.isRequired,
learningContextId: PropTypes.string,
lmsEndpointUrl: PropTypes.string,
onClose: PropTypes.func,
returnFunction: PropTypes.func,
studioEndpointUrl: PropTypes.string,
};

export default Editor;
6 changes: 6 additions & 0 deletions src/editors/EditorComponent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** Shared interface that all Editor components (like ProblemEditor) adhere to */
export interface EditorComponent {
onClose: (() => void) | null;
// TODO: get a better type for the 'result' here
returnFunction?: (() => (result: any) => void) | null;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';

import { Row, Stack } from '@openedx/paragon';
import ProblemTypeSelect from './content/ProblemTypeSelect';
Expand All @@ -9,7 +8,11 @@ import SelectTypeWrapper from './SelectTypeWrapper';
import * as hooks from './hooks';
import { AdvanceProblemKeys } from '../../../../data/constants/problem';

const SelectTypeModal = ({
interface Props {
onClose: (() => void) | null;
}

const SelectTypeModal: React.FC<Props> = ({
onClose,
}) => {
const { selected, setSelected } = hooks.selectHooks();
Expand All @@ -29,8 +32,4 @@ const SelectTypeModal = ({
);
};

SelectTypeModal.propTypes = {
onClose: PropTypes.func.isRequired,
};

export default SelectTypeModal;
5 changes: 2 additions & 3 deletions src/editors/containers/ProblemEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import { selectors, thunkActions } from '../../data/redux';
import { RequestKeys } from '../../data/constants/requests';
import messages from './messages';
import { ProblemType } from '../../data/constants/problem';
import type { EditorComponent } from '../../EditorComponent';

interface Props {
onClose: () => void | null;
returnFunction?: () => (result: any) => void | null;
export interface Props extends EditorComponent {
// redux
advancedSettingsFinished: boolean;
blockFinished: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ const supportedEditors = {
[blockTypes.video_upload]: VideoUploadEditor,
// ADDED_EDITORS GO BELOW
[blockTypes.game]: GameEditor,
};
} as const;

export default supportedEditors;

0 comments on commit fde5200

Please sign in to comment.