Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
useEffect( () => {
if (
calculatePriceRangeQueryState !== currentQueryPrices &&
currentQueryPrices !== undefined
) {
setCalculatePriceRangeQueryState( currentQueryPrices );
}
}, [
currentQueryPrices,
setCalculatePriceRangeQueryState,
calculatePriceRangeQueryState,
] );
// Defer the select query so all collection-data query vars can be gathered.
const [ shouldSelect, setShouldSelect ] = useState( false );
const [ debouncedShouldSelect ] = useDebounce( shouldSelect, 200 );
if ( ! shouldSelect ) {
setShouldSelect( true );
}
const collectionDataQueryVars = useMemo( () => {
return buildCollectionDataQuery( collectionDataQueryState );
}, [ collectionDataQueryState ] );
return useCollection( {
namespace: '/wc/store',
resourceName: 'products/collection-data',
query: {
...queryState,
page: undefined,
className,
setAttributes,
attributes,
isSelected,
} = props
const {
design = 'basic',
columns = 1,
showTitle = false,
titleTop = false,
titleTag = '',
} = props.attributes
const [ selected, setSelected ] = useState( false )
const [ urlPopupPosition, setUrlPopupPosition ] = useState( 'bottom center' )
const [ refreshPositionInterval, setRefreshPositionInterval ] = useState( null )
const show = showOptions( props )
const mainClasses = classnames( [
className,
`ugb-icon--design-${ design }`,
], applyFilters( 'stackable.icon.mainclasses', {
}, props ) )
// Updates the position of the url popup to be opposite of the icon popup.
const refreshPosition = () => {
const popover = document.querySelector( '.ugb-icon-popover' )
if ( popover ) {
if ( popover.classList.contains( 'is-from-top' ) ) {
setUrlPopupPosition( 'top center' )
function DateOption( { value, updateFilter } ) {
const selectedRange = value?.range || DATE_RANGE_ANY;
const [ month, setMonth ] = useState( -1 );
const [ year, setYear ] = useState( CURRENT_YEAR );
return (
<div>
updateFilter( { range } ) }
/>
{ selectedRange === DATE_RANGE_CUSTOM && (
</div>
function Dialog({ onClose, onSubmit }: Props) {
const { createErrorNotice } = useDispatch('core/notices');
const [isAddingManually, setIsAddingManually] = useState(false);
const [isBusy, setIsBusy] = useState(false);
const FORM_ID = 'add-reference-form';
return (
<>
{!isAddingManually && (
setIsBusy(busy)}
onClose={onClose}
onError={message =>
createErrorNotice(message, { type: 'snackbar' })
}
onSubmit={onSubmit}
/>
)}
function Switch( { label, checked, onChange } ) {
const [ on, setOn ] = useState( checked );
const handleChange = ( evt ) => {
setOn( evt.target.checked );
if ( onChange ) {
onChange( evt.target.checked );
}
};
useEffect( () => setOn( checked ), [ checked ] );
return (
<label>
{ label }
</label>
const ContextMenu = ( props ) => {
const {
clientIds,
clientX,
clientY,
insidePercentageX,
insidePercentageY,
} = props;
const [ isOpen, setIsOpen ] = useState( true );
const {
getBlock,
getBlockOrder,
getBlockRootClientId,
getSettings,
} = useSelect( ( select ) => select( 'core/block-editor' ), [] );
const {
getCopiedMarkup,
getCurrentPage,
} = useSelect( ( select ) => select( 'amp/story' ), [] );
const {
removeBlock,
insertBlock,
const useScreenDimensions = ( dimension = 'window' ) => {
const [ dimensions, setDimensions ] = useState( Dimensions.get( dimension ) );
useEffect( () => {
const onChange = ( result ) => {
setDimensions( result[ dimension ] );
};
Dimensions.addEventListener( 'change', onChange );
return () => Dimensions.removeEventListener( 'change', onChange );
} );
return dimensions;
};
export function ErrorContextProvider( { children } ) {
const [ error, setError ] = useState( error );
return (
{ children }
);
}
function DropZone( { children, onDrop, pageIndex, dragIndicatorOffset } ) {
const dropZoneElement = useRef( null );
const [ dropZone, setDropZone ] = useState( null );
const { actions: { registerDropZone, unregisterDropZone, resetHoverState }, state: { hoveredDropZone } } = useDropZone();
useLayoutEffect( () => {
setDropZone( {
node: dropZoneElement.current,
} );
}, [ dropZoneElement ] );
useLayoutEffect( () => {
registerDropZone( dropZone );
return () => {
unregisterDropZone( dropZone );
setDropZone( null );
};
}, [ dropZone, registerDropZone, unregisterDropZone ] );
const AttachmentContent = ( props ) => {
const [ selectedPost, setSelectedPost ] = useState( null );
const [ failedToFetch, setFailedToFetch ] = useState( false );
const [ searchValue, setSearchValue ] = useState( '' );
const [ isFetching, setIsFetching ] = useState( false );
const fetchRequest = useRef( null );
const isStillMounted = useRef( true );
const {
attributes,
setAttributes,
toggleAttachment,
} = props;
const {
attachmentClass,
postId,
postType,
title,
wrapperStyle,