How to use the @wordpress/is-shallow-equal function in @wordpress/is-shallow-equal

To help you get started, we’ve selected a few @wordpress/is-shallow-equal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Automattic / wp-calypso / client / components / data / query-posts / index.jsx View on Github external
UNSAFE_componentWillReceiveProps( nextProps ) {
		if (
			this.props.siteId === nextProps.siteId &&
			this.props.postId === nextProps.postId &&
			isShallowEqual( this.props.query, nextProps.query )
		) {
			return;
		}

		this.request( nextProps );
	}
github WordPress / gutenberg / packages / blocks / src / api / serializer.js View on Github external
if ( isObject( element ) && hasFilter( 'blocks.getSaveContent.extraProps' ) ) {
		/**
		 * Filters the props applied to the block save result element.
		 *
		 * @param {Object}      props      Props applied to save element.
		 * @param {WPBlockType} blockType  Block type definition.
		 * @param {Object}      attributes Block attributes.
		 */
		const props = applyFilters(
			'blocks.getSaveContent.extraProps',
			{ ...element.props },
			blockType,
			attributes
		);

		if ( ! isShallowEqual( props, element.props ) ) {
			element = cloneElement( element, props );
		}
	}

	/**
	 * Filters the save result of a block during serialization.
	 *
	 * @param {WPElement}   element    Block save result.
	 * @param {WPBlockType} blockType  Block type definition.
	 * @param {Object}      attributes Block attributes.
	 */
	element = applyFilters( 'blocks.getSaveElement', element, blockType, attributes );

	return (
		
			{ element }
github WordPress / gutenberg / packages / components / src / drop-zone / provider.js View on Github external
const index = this.dropZones.indexOf( dropZone );
			const isDraggingOverDropZone = index === hoveredDropZoneIndex;
			dropZone.setState( {
				isDraggingOverDocument: isTypeSupportedByDropZone( dragEventType, dropZone ),
				isDraggingOverElement: isDraggingOverDropZone,
				position: isDraggingOverDropZone ? position : null,
				type: isDraggingOverDropZone ? dragEventType : null,
			} );
		} );

		const newState = {
			isDraggingOverDocument: true,
			hoveredDropZone: hoveredDropZoneIndex,
			position,
		};
		if ( ! isShallowEqual( newState, this.state ) ) {
			this.setState( newState );
		}
	}
github php4dev / heroku-wordpress / wp-content / plugins / woo-gutenberg-products-block / assets / js / base / hocs / with-reviews.js View on Github external
shouldReplaceReviews( prevProps, nextProps ) {
			return (
				prevProps.orderby !== nextProps.orderby ||
				prevProps.order !== nextProps.order ||
				prevProps.productId !== nextProps.productId ||
				! isShallowEqual( prevProps.categoryIds, nextProps.categoryIds )
			);
		}
github WordPress / gutenberg / packages / compose / src / higher-order / pure / index.js View on Github external
shouldComponentUpdate( nextProps ) {
			return ! isShallowEqual( nextProps, this.props );
		}
github WordPress / gutenberg / packages / block-editor / src / components / inner-blocks / index.native.js View on Github external
updateNestedSettings() {
		const {
			blockListSettings,
			allowedBlocks,
			updateNestedSettings,
		} = this.props;

		const newSettings = {
			allowedBlocks,
			templateLock: this.getTemplateLock(),
		};

		if ( ! isShallowEqual( blockListSettings, newSettings ) ) {
			updateNestedSettings( newSettings );
		}
	}
github eventespresso / event-espresso-core / assets / src / vo / money.js View on Github external
hasSameCurrency( other ) {
		Money.assertMoney( other );
		return isShallowEqual(
			this.currency.toJSON(),
			other.currency.toJSON()
		);
	}
github ampproject / amp-wp / assets / src / stories-editor / helpers / snapping / createSnapList.js View on Github external
.find( ( snapLine ) =>
				isShallowEqual( item[ 0 ], snapLine[ 0 ] ) &&
				isShallowEqual( item[ 1 ], snapLine[ 1 ] ),
			);
github WordPress / gutenberg / packages / block-editor / src / components / inner-blocks / index.js View on Github external
updateNestedSettings() {
		const {
			blockListSettings,
			allowedBlocks,
			updateNestedSettings,
			templateLock,
			parentLock,
		} = this.props;

		const newSettings = {
			allowedBlocks,
			templateLock: templateLock === undefined ? parentLock : templateLock,
		};

		if ( ! isShallowEqual( blockListSettings, newSettings ) ) {
			updateNestedSettings( newSettings );
		}
	}
github WordPress / gutenberg / packages / block-editor / src / components / inner-blocks / index.js View on Github external
const {
			blockListSettings,
			allowedBlocks,
			updateNestedSettings,
			templateLock,
			parentLock,
			__experimentalCaptureToolbars,
		} = this.props;

		const newSettings = {
			allowedBlocks,
			templateLock: templateLock === undefined ? parentLock : templateLock,
			__experimentalCaptureToolbars: __experimentalCaptureToolbars || false,
		};

		if ( ! isShallowEqual( blockListSettings, newSettings ) ) {
			updateNestedSettings( newSettings );
		}
	}

@wordpress/is-shallow-equal

Test for shallow equality between two objects or arrays.

GPL-2.0-or-later
Latest version published 5 days ago

Package Health Score

98 / 100
Full package analysis