Skip to content

Commit

Permalink
fix: remove useEffect that fires before search params (openedx#465)
Browse files Browse the repository at this point in the history
* fix: remove useEffect that fires before search params

* fix: remove disable lint lines
  • Loading branch information
KristinAoki authored and BryanttV committed Apr 10, 2024
1 parent 6086ba4 commit 8ce0520
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/editors/containers/VideoEditor/components/VideoEditorModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,17 @@ import * as appHooks from '../../../hooks';
import { thunkActions, selectors } from '../../../data/redux';
import VideoSettingsModal from './VideoSettingsModal';
// import SelectVideoModal from './SelectVideoModal';
import * as module from './VideoEditorModal';

export const {
navigateTo,
} = appHooks;

export const hooks = {
initialize: (dispatch, selectedVideoId, selectedVideoUrl) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
dispatch(thunkActions.video.loadVideoData(selectedVideoId, selectedVideoUrl));
}, []);
dispatch(thunkActions.video.loadVideoData(selectedVideoId, selectedVideoUrl));
},
returnToGallery: () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
useReturnToGallery: () => {
const learningContextId = useSelector(selectors.app.learningContextId);
// eslint-disable-next-line react-hooks/rules-of-hooks
const blockId = useSelector(selectors.app.blockId);
return () => (navigateTo(`/course/${learningContextId}/editor/course-videos/${blockId}`));
},
Expand All @@ -36,8 +30,8 @@ const VideoEditorModal = ({
const searchParams = new URLSearchParams(document.location.search);
const selectedVideoId = searchParams.get('selectedVideoId');
const selectedVideoUrl = searchParams.get('selectedVideoUrl');
const onReturn = module.hooks.returnToGallery();
module.hooks.initialize(dispatch, selectedVideoId, selectedVideoUrl);
const onReturn = hooks.useReturnToGallery();
hooks.initialize(dispatch, selectedVideoId, selectedVideoUrl);
return (
<VideoSettingsModal {...{
close,
Expand Down

0 comments on commit 8ce0520

Please sign in to comment.