Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade React to 16.8.4: Welcome React Hooks #14400

Merged
merged 2 commits into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's surprising that react-test-renderer wasn't listed before 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react wasn't listed before.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right :)

"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
Copy link
Member

@aduth aduth Mar 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't the most helpful documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm Right I didn't notice, we might want to just link to the React Docs here. how can we improve this, I'm not yet familiar with this new doc generator @nosolosw

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do a couple of options:

  • Change this comment to Refer to React docs https://reactjs.org/docs/hooks-reference.html. That'd the quick/easy way.

  • Export every item independently as we did with the others. In the JSDoc comment, we can refer to the specific React hook reference like @see https://reactjs.org/docs/hooks-reference.html#usecallback.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm preparing a PR for the second option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome Thank you :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#14425 could be the minimum viable docs.


### 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