npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

use-is-editing-block

v1.0.0

Published

A React hook to determine if a WordPress block is being edited.

Readme

use-is-editing-block

A React hook for WordPress Gutenberg block development to determine if a block (parent or inner blocks) is being edited.

Installation

Install the package via npm:

npm install use-is-editing-block

Usage

This hook helps you determine if a specific Gutenberg block or its inner blocks are being edited.

Example:

import { useIsEditing } from 'use-is-editing-block';

const MyBlockComponent = ({ clientId }) => {
  const isEditing = useIsEditing(clientId, 'all');

  return <div>{isEditing ? 'Editing...' : 'Not editing'}</div>;
};

Arguments

  • clientId (string, required): The unique client ID of the Gutenberg block to check.
  • scope (string, optional): Determines the scope of the check:
    • 'parent': Checks if the parent block or its direct inner blocks are selected.
    • 'all' (default): Checks if the parent block or any nested inner block is selected/being edited.

Return Value

The hook returns a boolean value:

  • true: If the block or its specified inner blocks are being edited.
  • false: Otherwise.

Integration with WordPress Gutenberg Blocks

This hook is designed specifically for WordPress Gutenberg block development. It leverages the @wordpress/data package to interact with the block editor state.

Ensure your WordPress development environment includes the necessary dependencies, such as @wordpress/data and react.

Dependencies

Peer Dependencies

Ensure the following dependencies are installed in your project:

  • react: ^16.8.0 or newer.
  • @wordpress/data: The latest version compatible with your WordPress setup.

License

This package is licensed under the MIT License. See the LICENSE file for details.


For Contributors

If you'd like to contribute:

  1. Clone the repository:

    git clone https://github.com/sultann/use-is-editing-block.git
  2. Install dependencies:

    npm install
  3. Build the package:

    npm run build
  4. Test your changes in a WordPress Gutenberg block development environment.

Feel free to open issues or submit pull requests to improve this package!