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

@wordpress/element

Package Overview
Dependencies
Maintainers
10
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/element - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

23

build-module/react.js

@@ -7,3 +7,3 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";

*/
import { Children, cloneElement, Component, createContext, createElement, createRef, forwardRef, Fragment, isValidElement, StrictMode, useState, useEffect, useContext, useReducer, useCallback, useMemo, useRef, useImperativeHandle, useLayoutEffect, useDebugValue } from 'react';
import { Children, cloneElement, Component, createContext, createElement, createRef, forwardRef, Fragment, isValidElement, memo, StrictMode, useState, useEffect, useContext, useReducer, useCallback, useMemo, useRef, useImperativeHandle, useLayoutEffect, useDebugValue, lazy, Suspense } from 'react';
import { isString } from 'lodash';

@@ -90,2 +90,7 @@ /**

/**
* @see https://reactjs.org/docs/react-api.html#reactmemo
*/
export { memo };
/**
* Component that activates additional checks and warnings for its descendants.

@@ -146,2 +151,12 @@ */

/**
* @see https://reactjs.org/docs/react-api.html#reactlazy
*/
export { lazy };
/**
* @see https://reactjs.org/docs/react-api.html#reactsuspense
*/
export { Suspense };
/**
* Concatenate two or more React children objects.

@@ -159,3 +174,3 @@ *

return childrenArguments.reduce(function (memo, children, i) {
return childrenArguments.reduce(function (result, children, i) {
Children.forEach(children, function (child, j) {

@@ -168,5 +183,5 @@ if (child && 'string' !== typeof child) {

memo.push(child);
result.push(child);
});
return memo;
return result;
}, []);

@@ -173,0 +188,0 @@ }

@@ -64,2 +64,8 @@ "use strict";

});
Object.defineProperty(exports, "memo", {
enumerable: true,
get: function get() {
return _react.memo;
}
});
Object.defineProperty(exports, "StrictMode", {

@@ -131,2 +137,14 @@ enumerable: true,

});
Object.defineProperty(exports, "lazy", {
enumerable: true,
get: function get() {
return _react.lazy;
}
});
Object.defineProperty(exports, "Suspense", {
enumerable: true,
get: function get() {
return _react.Suspense;
}
});

@@ -216,2 +234,6 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));

/**
* @see https://reactjs.org/docs/react-api.html#reactmemo
*/
/**
* Component that activates additional checks and warnings for its descendants.

@@ -261,2 +283,10 @@ */

/**
* @see https://reactjs.org/docs/react-api.html#reactlazy
*/
/**
* @see https://reactjs.org/docs/react-api.html#reactsuspense
*/
/**
* Concatenate two or more React children objects.

@@ -273,3 +303,3 @@ *

return childrenArguments.reduce(function (memo, children, i) {
return childrenArguments.reduce(function (result, children, i) {
_react.Children.forEach(children, function (child, j) {

@@ -282,6 +312,6 @@ if (child && 'string' !== typeof child) {

memo.push(child);
result.push(child);
});
return memo;
return result;
}, []);

@@ -288,0 +318,0 @@ }

@@ -0,1 +1,23 @@

## 2.4.0 (Unreleased)
### New Features
- Added `lazy` feautre (see: https://reactjs.org/docs/react-api.html#reactlazy).
- Added `Suspense` component (see: https://reactjs.org/docs/react-api.html#reactsuspense).
## 2.3.0 (2019-03-06)
### New Features
- Added `useCallback` hook (see: https://reactjs.org/docs/hooks-reference.html#usecallback).
- Added `useContext` hook (see: https://reactjs.org/docs/hooks-reference.html#usecontext).
- Added `useDebugValue` hook (see: https://reactjs.org/docs/hooks-reference.html#usedebugvalue).
- Added `useEffect` hook (see: https://reactjs.org/docs/hooks-reference.html#useeffect).
- Added `useImperativeHandle` hook (see: https://reactjs.org/docs/hooks-reference.html#useimperativehandle).
- Added `useLayoutEffect` hook (see: https://reactjs.org/docs/hooks-reference.html#uselayouteffect).
- Added `useMemo` hook (see: https://reactjs.org/docs/hooks-reference.html#usememo).
- Added `useReducer` hook (see: https://reactjs.org/docs/hooks-reference.html#usereducer).
- Added `useRef` hook (see: https://reactjs.org/docs/hooks-reference.html#useref).
- Added `useState` hook (see: https://reactjs.org/docs/hooks-reference.html#usestate).
## 2.1.8 (2018-11-15)

@@ -2,0 +24,0 @@

8

package.json
{
"name": "@wordpress/element",
"version": "2.3.0",
"version": "2.4.0",
"description": "Element React module for WordPress.",

@@ -25,4 +25,4 @@ "author": "The WordPress Contributors",

"dependencies": {
"@babel/runtime": "^7.3.1",
"@wordpress/escape-html": "^1.2.0",
"@babel/runtime": "^7.4.4",
"@wordpress/escape-html": "^1.3.0",
"lodash": "^4.17.11",

@@ -35,3 +35,3 @@ "react": "^16.8.4",

},
"gitHead": "1e024a20a20369af7bc9720a676fdd3837a3a105"
"gitHead": "87f92f8f58a14a58b44beff0919734c546b3b975"
}

@@ -81,93 +81,77 @@ # Element

### Children
<a name="Children" href="#Children">#</a> **Children**
[src/index.js#L1-L1](src/index.js#L1-L1)
Object that provides utilities for dealing with React children.
### cloneElement
<a name="cloneElement" href="#cloneElement">#</a> **cloneElement**
[src/index.js#L1-L1](src/index.js#L1-L1)
Creates a copy of an element with extended props.
**Parameters**
_Parameters_
- **element** `WPElement`: Element
- **props** `?Object`: Props to apply to cloned element
- _element_ `WPElement`: Element
- _props_ `?Object`: Props to apply to cloned element
**Returns**
_Returns_
`WPElement`: Cloned element.
- `WPElement`: Cloned element.
### Component
<a name="Component" href="#Component">#</a> **Component**
[src/index.js#L1-L1](src/index.js#L1-L1)
A base class to create WordPress Components (Refs, state and lifecycle hooks)
### concatChildren
<a name="concatChildren" href="#concatChildren">#</a> **concatChildren**
[src/index.js#L1-L1](src/index.js#L1-L1)
Concatenate two or more React children objects.
**Parameters**
_Parameters_
- **childrenArguments** `...?Object`: Array of children arguments (array of arrays/strings/objects) to concatenate.
- _childrenArguments_ `...?Object`: Array of children arguments (array of arrays/strings/objects) to concatenate.
**Returns**
_Returns_
`Array`: The concatenated value.
- `Array`: The concatenated value.
### createContext
<a name="createContext" href="#createContext">#</a> **createContext**
[src/index.js#L1-L1](src/index.js#L1-L1)
Creates a context object containing two components: a provider and consumer.
**Parameters**
_Parameters_
- **defaultValue** `Object`: A default data stored in the context.
- _defaultValue_ `Object`: A default data stored in the context.
**Returns**
_Returns_
`Object`: Context object.
- `Object`: Context object.
### createElement
<a name="createElement" href="#createElement">#</a> **createElement**
[src/index.js#L1-L1](src/index.js#L1-L1)
Returns a new element of given type. Type can be either a string tag name or
another function which itself returns an element.
**Parameters**
_Parameters_
- **type** `?(string|Function)`: Tag name or element creator
- **props** `Object`: Element properties, either attribute set to apply to DOM node or values to pass through to element creator
- **children** `...WPElement`: Descendant elements
- _type_ `?(string|Function)`: Tag name or element creator
- _props_ `Object`: Element properties, either attribute set to apply to DOM node or values to pass through to element creator
- _children_ `...WPElement`: Descendant elements
**Returns**
_Returns_
`WPElement`: Element.
- `WPElement`: Element.
### createPortal
<a name="createPortal" href="#createPortal">#</a> **createPortal**
[src/index.js#L2-L2](src/index.js#L2-L2)
Creates a portal into which a component can be rendered.
**Related**
_Related_
- <https://github.com/facebook/react/issues/10309#issuecomment-318433235>
**Parameters**
_Parameters_
- **component** `Component`: Component
- **target** `Element`: DOM node into which element should be rendered
- _component_ `Component`: Component
- _target_ `Element`: DOM node into which element should be rendered
### createRef
<a name="createRef" href="#createRef">#</a> **createRef**
[src/index.js#L1-L1](src/index.js#L1-L1)
Returns an object tracking a reference to a rendered element via its

@@ -177,21 +161,17 @@ `current` property as either a DOMElement or Element, dependent upon the

**Returns**
_Returns_
`Object`: Ref object.
- `Object`: Ref object.
### findDOMNode
<a name="findDOMNode" href="#findDOMNode">#</a> **findDOMNode**
[src/index.js#L2-L2](src/index.js#L2-L2)
Finds the dom node of a React component
**Parameters**
_Parameters_
- **component** `Component`: component's instance
- **target** `Element`: DOM node into which element should be rendered
- _component_ `Component`: component's instance
- _target_ `Element`: DOM node into which element should be rendered
### forwardRef
<a name="forwardRef" href="#forwardRef">#</a> **forwardRef**
[src/index.js#L1-L1](src/index.js#L1-L1)
Component enhancer used to enable passing a ref to its wrapped component.

@@ -202,48 +182,52 @@ Pass a function argument which receives `props` and `ref` as its arguments,

**Parameters**
_Parameters_
- **forwarder** `Function`: Function passed `props` and `ref`, expected to return an element.
- _forwarder_ `Function`: Function passed `props` and `ref`, expected to return an element.
**Returns**
_Returns_
`WPComponent`: Enhanced component.
- `WPComponent`: Enhanced component.
### Fragment
<a name="Fragment" href="#Fragment">#</a> **Fragment**
[src/index.js#L1-L1](src/index.js#L1-L1)
A component which renders its children without any wrapping element.
### isEmptyElement
<a name="isEmptyElement" href="#isEmptyElement">#</a> **isEmptyElement**
[src/index.js#L3-L3](src/index.js#L3-L3)
Checks if the provided WP element is empty.
**Parameters**
_Parameters_
- **element** `*`: WP element to check.
- _element_ `*`: WP element to check.
**Returns**
_Returns_
`boolean`: True when an element is considered empty.
- `boolean`: True when an element is considered empty.
### isValidElement
<a name="isValidElement" href="#isValidElement">#</a> **isValidElement**
[src/index.js#L1-L1](src/index.js#L1-L1)
Checks if an object is a valid WPElement
**Parameters**
_Parameters_
- **objectToCheck** `Object`: The object to be checked.
- _objectToCheck_ `Object`: The object to be checked.
**Returns**
_Returns_
`boolean`: true if objectToTest is a valid WPElement and false otherwise.
- `boolean`: true if objectToTest is a valid WPElement and false otherwise.
### RawHTML
<a name="lazy" href="#lazy">#</a> **lazy**
[src/index.js#L5-L5](src/index.js#L5-L5)
_Related_
- <https://reactjs.org/docs/react-api.html#reactlazy>
<a name="memo" href="#memo">#</a> **memo**
_Related_
- <https://reactjs.org/docs/react-api.html#reactmemo>
<a name="RawHTML" href="#RawHTML">#</a> **RawHTML**
Component used as equivalent of Fragment with unescaped HTML, in cases where

@@ -254,146 +238,122 @@ it is desirable to render dangerous HTML without needing a wrapper element.

**Parameters**
_Parameters_
- **props.children** `string`: HTML to render.
- _props.children_ `string`: HTML to render.
**Returns**
_Returns_
`WPElement`: Dangerously-rendering element.
- `WPElement`: Dangerously-rendering element.
### render
<a name="render" href="#render">#</a> **render**
[src/index.js#L2-L2](src/index.js#L2-L2)
Renders a given element into the target DOM node.
**Parameters**
_Parameters_
- **element** `WPElement`: Element to render
- **target** `Element`: DOM node into which element should be rendered
- _element_ `WPElement`: Element to render
- _target_ `Element`: DOM node into which element should be rendered
### renderToString
<a name="renderToString" href="#renderToString">#</a> **renderToString**
[src/index.js#L4-L4](src/index.js#L4-L4)
Serializes a React element to string.
**Parameters**
_Parameters_
- **element** `WPElement`: Element to serialize.
- **context** `?Object`: Context object.
- **legacyContext** `?Object`: Legacy context object.
- _element_ `WPElement`: Element to serialize.
- _context_ `?Object`: Context object.
- _legacyContext_ `?Object`: Legacy context object.
**Returns**
_Returns_
`string`: Serialized element.
- `string`: Serialized element.
### StrictMode
<a name="StrictMode" href="#StrictMode">#</a> **StrictMode**
[src/index.js#L1-L1](src/index.js#L1-L1)
Component that activates additional checks and warnings for its descendants.
### switchChildrenNodeName
<a name="Suspense" href="#Suspense">#</a> **Suspense**
[src/index.js#L1-L1](src/index.js#L1-L1)
_Related_
- <https://reactjs.org/docs/react-api.html#reactsuspense>
<a name="switchChildrenNodeName" href="#switchChildrenNodeName">#</a> **switchChildrenNodeName**
Switches the nodeName of all the elements in the children object.
**Parameters**
_Parameters_
- **children** `?Object`: Children object.
- **nodeName** `string`: Node name.
- _children_ `?Object`: Children object.
- _nodeName_ `string`: Node name.
**Returns**
_Returns_
`?Object`: The updated children object.
- `?Object`: The updated children object.
### unmountComponentAtNode
<a name="unmountComponentAtNode" href="#unmountComponentAtNode">#</a> **unmountComponentAtNode**
[src/index.js#L2-L2](src/index.js#L2-L2)
Removes any mounted element from the target DOM node.
**Parameters**
_Parameters_
- **target** `Element`: DOM node in which element is to be removed
- _target_ `Element`: DOM node in which element is to be removed
### useCallback
<a name="useCallback" href="#useCallback">#</a> **useCallback**
[src/index.js#L1-L1](src/index.js#L1-L1)
_Related_
**Related**
- <https://reactjs.org/docs/hooks-reference.html#usecallback>
### useContext
<a name="useContext" href="#useContext">#</a> **useContext**
[src/index.js#L1-L1](src/index.js#L1-L1)
_Related_
**Related**
- <https://reactjs.org/docs/hooks-reference.html#usecontext>
### useDebugValue
<a name="useDebugValue" href="#useDebugValue">#</a> **useDebugValue**
[src/index.js#L1-L1](src/index.js#L1-L1)
_Related_
**Related**
- <https://reactjs.org/docs/hooks-reference.html#usedebugvalue>
### useEffect
<a name="useEffect" href="#useEffect">#</a> **useEffect**
[src/index.js#L1-L1](src/index.js#L1-L1)
_Related_
**Related**
- <https://reactjs.org/docs/hooks-reference.html#useeffect>
### useImperativeHandle
<a name="useImperativeHandle" href="#useImperativeHandle">#</a> **useImperativeHandle**
[src/index.js#L1-L1](src/index.js#L1-L1)
_Related_
**Related**
- <https://reactjs.org/docs/hooks-reference.html#useimperativehandle>
### useLayoutEffect
<a name="useLayoutEffect" href="#useLayoutEffect">#</a> **useLayoutEffect**
[src/index.js#L1-L1](src/index.js#L1-L1)
_Related_
**Related**
- <https://reactjs.org/docs/hooks-reference.html#uselayouteffect>
### useMemo
<a name="useMemo" href="#useMemo">#</a> **useMemo**
[src/index.js#L1-L1](src/index.js#L1-L1)
_Related_
**Related**
- <https://reactjs.org/docs/hooks-reference.html#usememo>
### useReducer
<a name="useReducer" href="#useReducer">#</a> **useReducer**
[src/index.js#L1-L1](src/index.js#L1-L1)
_Related_
**Related**
- <https://reactjs.org/docs/hooks-reference.html#usereducer>
### useRef
<a name="useRef" href="#useRef">#</a> **useRef**
[src/index.js#L1-L1](src/index.js#L1-L1)
_Related_
**Related**
- <https://reactjs.org/docs/hooks-reference.html#useref>
### useState
<a name="useState" href="#useState">#</a> **useState**
[src/index.js#L1-L1](src/index.js#L1-L1)
_Related_
**Related**
- <https://reactjs.org/docs/hooks-reference.html#usestate>

@@ -400,0 +360,0 @@

@@ -14,2 +14,3 @@ /**

isValidElement,
memo,
StrictMode,

@@ -26,2 +27,4 @@ useState,

useDebugValue,
lazy,
Suspense,
} from 'react';

@@ -110,2 +113,7 @@ import { isString } from 'lodash';

/**
* @see https://reactjs.org/docs/react-api.html#reactmemo
*/
export { memo };
/**
* Component that activates additional checks and warnings for its descendants.

@@ -166,2 +174,12 @@ */

/**
* @see https://reactjs.org/docs/react-api.html#reactlazy
*/
export { lazy };
/**
* @see https://reactjs.org/docs/react-api.html#reactsuspense
*/
export { Suspense };
/**
* Concatenate two or more React children objects.

@@ -174,3 +192,3 @@ *

export function concatChildren( ...childrenArguments ) {
return childrenArguments.reduce( ( memo, children, i ) => {
return childrenArguments.reduce( ( result, children, i ) => {
Children.forEach( children, ( child, j ) => {

@@ -183,6 +201,6 @@ if ( child && 'string' !== typeof child ) {

memo.push( child );
result.push( child );
} );
return memo;
return result;
}, [] );

@@ -189,0 +207,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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