Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove useEffect that fires before search params #465

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import { thunkActions, selectors } from '../../../data/redux';
import VideoSettingsModal from './VideoSettingsModal';
// import SelectVideoModal from './SelectVideoModal';
import * as module from './VideoEditorModal';

export const {
navigateTo,
Expand All @@ -14,9 +13,7 @@
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));

Check warning on line 16 in src/editors/containers/VideoEditor/components/VideoEditorModal.jsx

View check run for this annotation

Codecov / codecov/patch

src/editors/containers/VideoEditor/components/VideoEditorModal.jsx#L16

Added line #L16 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:
The rules-of-hooks disable in L15 can be removed.
If returnToGallery is renamed to useReturnToGallery, the other rules-of-hooks disables can be removed as well.

},
returnToGallery: () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
Expand All @@ -36,8 +33,8 @@
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.returnToGallery();
hooks.initialize(dispatch, selectedVideoId, selectedVideoUrl);

Check warning on line 37 in src/editors/containers/VideoEditor/components/VideoEditorModal.jsx

View check run for this annotation

Codecov / codecov/patch

src/editors/containers/VideoEditor/components/VideoEditorModal.jsx#L36-L37

Added lines #L36 - L37 were not covered by tests
return (
<VideoSettingsModal {...{
close,
Expand Down
Loading