Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
move view names inside useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhtungdu committed Dec 13, 2021
1 parent 040cec8 commit 9ecc545
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions assets/js/blocks/cart-checkout/shared/use-view-switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const useViewSwitcher = (
} => {
const initialView = views[ 0 ];
const [ currentView, setCurrentView ] = useState( initialView );
const viewNames = views.map( ( { view } ) => view );
const { selectBlock } = useDispatch( 'core/block-editor' );
const {
getBlock,
Expand All @@ -33,6 +32,7 @@ export const useViewSwitcher = (
const selectedBlockClientId = getSelectedBlockClientId();

useEffect( () => {
const viewNames = views.map( ( { view } ) => view );
const parentBlockIds = getBlockParentsByBlockName(
selectedBlockClientId,
viewNames
Expand All @@ -59,7 +59,6 @@ export const useViewSwitcher = (
}, [
getBlockParentsByBlockName,
selectedBlockClientId,
viewNames,
getBlock,
currentView.view,
views,
Expand Down

0 comments on commit 9ecc545

Please sign in to comment.