Skip to content

Commit

Permalink
Upgrade React to 16.8.4: Welcome React Hooks (#13992)
Browse files Browse the repository at this point in the history
* Upgrade React to 16.8.4

* Update package-lock.json file

* Expose React Hooks
  • Loading branch information
youknowriad committed Mar 13, 2019
1 parent 9f3f392 commit 630e7bb
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 47 deletions.
19 changes: 15 additions & 4 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,21 @@ function gutenberg_register_scripts_and_styles() {
* @since 0.1.0
*/
function gutenberg_register_vendor_scripts() {
/*
* This function is kept as an empty stub, in case Gutenberg should need to
* explicitly provide a version newer than that provided by core.
*/
$suffix = SCRIPT_DEBUG ? '' : '.min';

// Vendor Scripts.
$react_suffix = ( SCRIPT_DEBUG ? '.development' : '.production' ) . $suffix;

gutenberg_register_vendor_script(
'react',
'https://unpkg.com/[email protected]/umd/react' . $react_suffix . '.js',
array( 'wp-polyfill' )
);
gutenberg_register_vendor_script(
'react-dom',
'https://unpkg.com/[email protected]/umd/react-dom' . $react_suffix . '.js',
array( 'react' )
);
}

/**
Expand Down
123 changes: 88 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@
"pegjs": "0.10.0",
"phpegjs": "1.0.0-beta7",
"postcss": "7.0.13",
"react-dom": "16.6.3",
"react-test-renderer": "16.6.3",
"react": "16.8.4",
"react-dom": "16.8.4",
"react-test-renderer": "16.8.4",
"redux": "4.0.0",
"rimraf": "2.6.2",
"rtlcss": "2.4.0",
Expand Down
60 changes: 60 additions & 0 deletions packages/element/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,66 @@ Removes any mounted element from the target DOM node.

- **target** `Element`: DOM node in which element is to be removed

### useCallback

[src/index.js#L1-L1](src/index.js#L1-L1)

Make React Hooks available

### useContext

[src/index.js#L1-L1](src/index.js#L1-L1)

Make React Hooks available

### useDebugValue

[src/index.js#L1-L1](src/index.js#L1-L1)

Make React Hooks available

### useEffect

[src/index.js#L1-L1](src/index.js#L1-L1)

Make React Hooks available

### useImperativeHandle

[src/index.js#L1-L1](src/index.js#L1-L1)

Make React Hooks available

### useLayoutEffect

[src/index.js#L1-L1](src/index.js#L1-L1)

Make React Hooks available

### useMemo

[src/index.js#L1-L1](src/index.js#L1-L1)

Make React Hooks available

### useReducer

[src/index.js#L1-L1](src/index.js#L1-L1)

Make React Hooks available

### useRef

[src/index.js#L1-L1](src/index.js#L1-L1)

Make React Hooks available

### useState

[src/index.js#L1-L1](src/index.js#L1-L1)

Make React Hooks available


<!-- END TOKEN(Autogenerated API docs) -->

Expand Down
4 changes: 2 additions & 2 deletions packages/element/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"@babel/runtime": "^7.3.1",
"@wordpress/escape-html": "file:../escape-html",
"lodash": "^4.17.11",
"react": "^16.6.3",
"react-dom": "^16.6.3"
"react": "^16.8.4",
"react-dom": "^16.8.4"
},
"publishConfig": {
"access": "public"
Expand Down
26 changes: 26 additions & 0 deletions packages/element/src/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ import {
Fragment,
isValidElement,
StrictMode,
useState,
useEffect,
useContext,
useReducer,
useCallback,
useMemo,
useRef,
useImperativeHandle,
useLayoutEffect,
useDebugValue,
} from 'react';
import { isString } from 'lodash';

Expand Down Expand Up @@ -99,6 +109,22 @@ export { isValidElement };
*/
export { StrictMode };

/**
* Make React Hooks available
*/
export {
useCallback,
useContext,
useDebugValue,
useEffect,
useImperativeHandle,
useLayoutEffect,
useMemo,
useReducer,
useRef,
useState,
};

/**
* Concatenate two or more React children objects.
*
Expand Down
8 changes: 4 additions & 4 deletions phpunit/class-vendor-script-filename-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ function vendor_script_filename_cases() {
// Development mode scripts.
array(
'react-handle',
'https://unpkg.com/react@16.6.3/umd/react.development.js',
'https://unpkg.com/react@16.8.4/umd/react.development.js',
'react-handle.HASH.js',
),
array(
'react-dom-handle',
'https://unpkg.com/react-dom@16.6.3/umd/react-dom.development.js',
'https://unpkg.com/react-dom@16.8.4/umd/react-dom.development.js',
'react-dom-handle.HASH.js',
),
// Production mode scripts.
array(
'react-handle',
'https://unpkg.com/react@16.6.3/umd/react.production.min.js',
'https://unpkg.com/react@16.8.4/umd/react.production.min.js',
'react-handle.min.HASH.js',
),
array(
'react-dom-handle',
'https://unpkg.com/react-dom@16.6.3/umd/react-dom.production.min.js',
'https://unpkg.com/react-dom@16.8.4/umd/react-dom.production.min.js',
'react-dom-handle.min.HASH.js',
),
// Other cases.
Expand Down

0 comments on commit 630e7bb

Please sign in to comment.