Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wordpress/element

Package Overview
Dependencies
Maintainers
23
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/element

Element React module for WordPress.

  • 6.14.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
189K
decreased by-7.61%
Maintainers
23
Weekly downloads
 
Created

What is @wordpress/element?

@wordpress/element is a package that provides utilities for working with React elements in the context of WordPress. It is essentially a thin abstraction layer over React, tailored to integrate seamlessly with the WordPress ecosystem.

What are @wordpress/element's main functionalities?

Creating Elements

This feature allows you to create React elements using the `createElement` function, which is similar to React's `React.createElement`.

const { createElement } = require('@wordpress/element');
const element = createElement('div', { className: 'my-class' }, 'Hello World');

Component Class

You can define class components using the `Component` class provided by @wordpress/element, similar to React's `React.Component`.

const { Component } = require('@wordpress/element');
class MyComponent extends Component {
  render() {
    return createElement('div', null, 'Hello from MyComponent');
  }
}

Hooks

The package supports React hooks like `useState`, allowing you to manage state in functional components.

const { useState } = require('@wordpress/element');
function MyFunctionalComponent() {
  const [count, setCount] = useState(0);
  return createElement('button', { onClick: () => setCount(count + 1) }, `Count: ${count}`);
}

Other packages similar to @wordpress/element

Keywords

FAQs

Package last updated on 11 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc