Compare commits

...

66 Commits

Author SHA1 Message Date
Brian Vaughn
c3718c48f0 16 beta 5 version bump and results JSON 2017-08-08 10:25:25 -07:00
Brian Vaughn
1724b116cd Enable new fiber ReactTestRenderer API methods (#10410)
Enable new fiber ReactTestRenderer API methods
2017-08-08 10:17:59 -07:00
Andrew Clark
5cdd744e06 Fix bugs related to unmounting error boundaries (#10403)
* Don't warn about setState on unmounted when scheduling error recovery

We shouldn't schedule an update on unmounted error boundaries, but we
don't know if a boundary is unmounted until we traverse its parents.
Added an additional argument to scheduleUpdate so we know not to warn
about setState on unmounted components.

* Should be able to unmount an error boundary before it is handled

Fixes the case where an error boundary captures an error, but its
parent is unmounted before we can re-render it. componentDidCatch is
never called, and we don't remove the boundary from our set of
unhandled error boundaries.

We should not assume that if capturedErrors is non-null that we still
have unhandled errors.
2017-08-08 10:09:43 -07:00
Brian Vaughn
9ebd0c9e9a Updated packages and results JSON for 16 beta 4 2017-08-08 09:08:17 -07:00
Rodrigo Pombo
fc3fb4bd72 Fiber debugger enhancements (#10393)
* Add effect tag

* Add graph settings (direction and trackActive)

* Support multiple effect tags
2017-08-08 11:31:48 +01:00
Ben Alpert
a6e20d0bd8 Add traversal for Fiber test renderer (#10377)
Not clear the path to shipping this but this gives us a migration path internally that we need right now (replaces https://fburl.com/udq9ksvk).
2017-08-07 16:47:22 -07:00
Dan Abramov
efcac24af2 Remove data-reactid and data-reactchecksum from whitelist (#10402) 2017-08-07 21:28:26 +01:00
Dan Abramov
4e4653da9b Rewrite DOMPropertyOperations-test in terms of public API (#10281)
* Rewrite DOMPropertyOperations-test in terms of public API

* Add more assertions

I don't understand what the jsdom comments are about since they pass.

* Address review feedback
2017-08-07 20:12:13 +01:00
Ben Alpert
7aec5f8f49 Update installation.md 2017-08-04 17:10:50 -07:00
Rodrigo Pombo
07acd7db81 [fiber-debugger] Support undefined progressedPriority (#10375)
[fiber-debugger] Fix the debugger to match changes to Fiber
2017-08-04 19:45:20 +01:00
Dan Abramov
145986ec17 Compile spread to Object.assign calls (#10387) 2017-08-04 19:12:12 +01:00
Dan Abramov
327d126392 Move PooledClass to Stack folder (#10386) 2017-08-04 19:10:07 +01:00
Brandon Dail
755724a24c Implement event-specific pooling for SyntheticEvent (#10237)
* Remove PooledClass from FallbackCompositionState

The only module that uses FallbackCompositonState is BeforeInputEventPlugin. The way its structured means there can only be a single instance of FallbackCompositionState at any given time (stored in a local variable at the top-level) so we don't really need pooling here at all. Instead, a single object is now stored in FallbackCompositionState, and access (initializing, reseting, getting data) is gaurded by the exported helper object.

* Use new FallbackCompositionState API in BeforeInputEventPlugin

* Implement event-specific pooling in SyntheticEvent

* Remove PooledClass from TopLevelCallbackBookKeeping

* Update results.json

* Add pooled event test fixtures (#1)

* Fix fixture lint
2017-08-04 18:24:48 +01:00
Dan Abramov
efa71484b3 Warn about unresolved function as a child (#10376)
* Warn about unresolved function as a child

* Oops
2017-08-04 15:51:47 +01:00
Nathan Hunzaker
6f28ecf0cb Fix incorrect reference to undefined diffValueForAttribute (#10235)
* Fix incorrect reference to undefined diffValueForAttribute

* Remove custom attribute branch in getValueForProperty
2017-08-04 14:47:28 +01:00
Devedse
25894e82c2 Wop optimized this repository (#10374)
The Web Optimization Project optimized this repository. This commit contains the optimized files in this repository.
2017-08-04 14:41:38 +01:00
Brian Vaughn
230d41218e Built 16.0.0 beta 3. Updated versions, results.json, and error codes 2017-08-03 16:05:28 -07:00
Brian Vaughn
6188832c5e Log captured errors sooner (#10373)
This prevents the captured error from becoming separated from the component stack if other errors (or console.error calls) are made between them, eg a component errors during unmount.
2017-08-03 15:51:09 -07:00
Dan Abramov
80577eb649 Don't call componentDidUpdate() in shallow renderer (#10372)
* Don't call componentDidUpdate() in shallow renderer

* Lint

Sent from my iPhone haha

* Consistent comments
2017-08-03 22:49:29 +01:00
Dan Abramov
a130757cd3 Remove hidden functional shouldComponentUpdate API (#10371) 2017-08-03 20:24:09 +01:00
Andrew Clark
a650699d2f Cross-origin error handling in DEV (#10353)
* Add DOM fixture for cross-origin errors

* Use a custom error object in place of cross-origin errors

Cross-origin errors aren't accessible by React in DEV mode because we
catch errors using a global error handler, in order to preserve the
"Pause on exceptions" behavior of the DevTools. When this happens, we
should use a custom error object that explains what happened.

For uncaught errors, the actual error message is logged to the console
by the browser, so React should skip logging the message again.

* Add test case that demonstrates errors are logged even if they're caught

* Don't double log error messages in DEV

In DEV, the browser always logs errors thrown inside React components,
even if the originating update is wrapped in a try-catch, because of the
dispatchEvent trick used by invokeGuardedCallback. So the error logger
should not log the message again.

* Fix tests

* Change how error is printed in DEV and PROD

In DEV, we don't want to print the stack trace because the browser already always prints it.
We'll just print the component stack now.

In PROD, we used to omit the JS error message. However we *do* want to show it because
if the application swallows the error, the browser will *not* print it. In DEV it works
only because of the fake event trick. So in PROD we will always print the underlying error
by logging the error object directly. This will show both the message and the JS stack.

* Make the wording tighter and emphasize the real error is above

There's a few goals in the rewording:

* Make it tighter using line breaks between sentences.
* Make it slightly less patronizing ("You should fix it" => "You can find its details in an earlier log")
* ^^ This also helps highlight that the real error message and stack is above
* Group subsections: intro (there's an error), component stack, and final addendum about error boundaries
* ^^ Otherwise people might think error boundaries are part of the reason they have an error
* Make it clear "located at" is not the stacktrace. Otherwise it feels confusing. This makes it clearer you should still look for stack trace (with other details) above and introduces the concept of component stack.

* Make the message shorter

* Unused variables

* Fix an error caused by fixing lint

* One more bikeshed

* Fix fixture

* Remove unused file

* Concise wording

* Unused variables
2017-08-03 18:25:53 +01:00
Brian Vaughn
028e0ea937 Fix lint error in DOM fixtures (#10369) 2017-08-03 17:32:04 +01:00
Dan Abramov
03ca99d9ba Add documentation about <script crossorigin> for React CDN usage (#10368) 2017-08-03 16:13:13 +01:00
Jason Quense
0b220d0f04 Remove old IE polyfill code (#10238)
* Upgrade DOM Fixtures

Upgrade to react-scripts v1 and include required polyfills for older
browsers

* Remove ChangeEvent polyfills for unsupported browsers
2017-08-03 13:45:41 +01:00
Dan Abramov
c1833b4b7e Fix CI maybe 2017-08-03 00:59:40 +01:00
Dan Abramov
fc86ef0f3d Use single entry point for SSR via browser field (#10362)
* Use single entry point for SSR via browser field

* Add server.browser entry point and smoke tests

* Tweak bundle naming

* Fix import

* Re-record

* Fix the robot nits

* Add resetModules for some extra isolation
2017-08-03 00:41:09 +01:00
Brian Vaughn
630afb3186 Wrap contents of if-DEV condition in an IIFE (#10361)
This avoids strict mode conflicts for certain browsers wrt functions being defined within an if-block.
Also re-added the if-DEV condition for the ReactNative renderer since it was removed for this reason.
2017-08-02 14:24:43 -07:00
Brian Vaughn
f3e502c613 FB bundles wrap warning() calls in __DEV__ (#10314)
FB bundles wrap warning() calls in __DEV__

Split dev-mode transforms into separate parts:
1) umd+cjs+fb: Wrap warning calls with process.env checks
2) umd+cjs: Replace error messages with minified codes

Also updated transforms to use __DEV__ since it transforms to smaller code after stripEnvVariables is run.

Also renamed 'scripts/error-codes/dev-expression-with-codes.js' -> 'scripts/error-codes/replace-invariant-error-codes.js'
2017-08-02 14:14:26 -07:00
Dan Abramov
8890db707b Don't suggest downloading React DevTools inside Chrome extension (#10359) 2017-08-02 20:04:49 +01:00
Dan Abramov
9823808632 Upsell React DevTools in 16 (#10351)
* Upsell React DevTools

* Fix Flow

* Upsell message nits

* Avoid extra checks in onCommitRoot and onCommitUnmount
2017-08-02 18:56:24 +01:00
Dan Abramov
4e6cc2f495 Warn on missing Set/Map polyfills (#10356)
* Crash on missing Set/Map polyfills

* Change Map/Set to emit warnings instead

* Change rAF polyfill check to also be a warning

* Liiiiiint
2017-08-02 18:55:18 +01:00
Toru Kobayashi
ffec3be560 Remove an unnecessary __DEV__ condition (#10350) 2017-08-02 17:57:41 +01:00
Brian Vaughn
2da37a8a44 Shallow renderer passes context to componentWillReceiveProps (#10342)
This parameter was accidentally omitted before. Leland reported it because it impacts Enzyme.
I also added a basic lifecycle parameter test for shallow renderer.
2017-08-02 08:18:46 -07:00
Andrew Clark
372445735e Remove rAF export from ReactDOMFrameScheduling (#10337)
Fiber doesn't schedule animation callbacks anymore (though it does use
the browser's requestAnimationFrame to polyfill requestIdleCallback).

This removes the rAF export from ReactDOMFrameScheduling, since it's not
being used.
2017-08-02 19:56:37 +05:30
Nathan Hunzaker
81706eeb7a Remove event namespace check from react-partial-renderer (#10344) 2017-08-02 11:30:44 +01:00
Toru Kobayashi
7917709782 Fix a typo (#10349) 2017-08-02 11:09:09 +01:00
Michał Pierzchała
73217a74a0 Fix error-codes not updating correctly (#10348)
* Fix error-codes not updating correctly

* Revert changes to codes.json
2017-08-02 10:38:27 +01:00
Greg Hurrell
c5d1558a5b Grammar fixes for a code comment (#10343) 2017-08-02 01:20:53 +01:00
Dan Abramov
35e3133610 Remove hydrate() warning about empty container (#10345)
* Remove hydrate() warning about empty container

It used to have false positives for cases where we legitimately don't render anything.

* Use existing constant

* Test empty string case using its parent
2017-08-02 01:05:56 +01:00
Dan Abramov
a43ba2625b Add an extra test for arrays and strings from composites (#10346) 2017-08-02 01:05:42 +01:00
Dan Abramov
f8062df1d6 Add ReactDOM.hydrate() as explicit SSR hydration API (#10339)
* Add ReactDOM.hydrate()

* Deprecate ReactDOM.render() hydration in favor of ReactDOM.hydrate()

* Downgrade the warning level to console.warn()

* Warn when hydrate() is called with empty container
2017-08-01 21:17:24 +01:00
Dan Abramov
a2ed7a6d96 Make unexpected console.warn() calls fail tests (#10341)
* Make console.warn() calls fail tests

* Replace matchers with a more straightforward cleanup
2017-08-01 19:53:37 +01:00
Brian Vaughn
d947654913 Context improvements (#10334)
Refactored fiber context to fix a nested updates bug
2017-08-01 08:38:54 -07:00
Dan Abramov
78165276c7 Test for specific SSR warning (#10340)
* Test for specific SSR warning

* Same in another place
2017-08-01 14:38:17 +01:00
Jack Ford
04db3511fe Remove trapBubbledEventsLocal (#10258)
* Inline trapBubbledEventsLocal

* Revert "Inline trapBubbledEventsLocal"

This reverts commit 0ee65ff491deeec70223c2e39d04ef0aeda95d73.

* Merge remove-local-trap-bubbled-events branch
2017-08-01 08:37:26 +01:00
Toru Kobayashi
73038840ef Move ShallowRenderer tests (#10184) 2017-08-01 08:27:28 +01:00
Toru Kobayashi
56cd54f0ad Add tests that ShallowRenderer supports string and fragment (#10241) 2017-08-01 00:39:43 +01:00
Dan Abramov
1454f9c10c Fix invariant parity for SSR (#10333) 2017-07-31 21:13:50 +01:00
Dan Abramov
67347a6459 Fix SSR integration test swallowing lack of expected error (#10331)
* Don't catch the assertion about missing errors

Previously, even if an error was not thrown, the assertion about this was ignored.

This fix exposes two failing cases in new SSR that weren't failing in Stack.

* Add child context validation to new SSR

This fixes the error cases that were silently failing before but are now exposed.
2017-07-31 17:57:05 +01:00
guoyong yi
f732fc677b fix renderToString fails with array type children when react-dom/server render (#10221)
* fix(*): fix renderToString fails with array type children when react-dom/server render

* Add an integration test that verify renderToString with array type children

* Add integration test to renderToString with array type child

* Update integration test to renderToString with array type child

* fix renderToString fails with array type children when react-dom/server render

* Update integration test to renderToString with array type child

* Add to iterate that are not arrays

* Add the validation react element

* Improve an integration test of server renderToString with array type

* prettier

* prettier

* Make SSR can handle a single array element and nested array

* prettier

* Change integeration test description

* 	modified:   src/renderers/dom/ReactDOMNodeStreamRenderer.js

* Make invariants consistent

* Gate outdated test itself by feature flag

* Change test to make sense both with old and new code

* Test more cases
2017-07-31 16:59:14 +01:00
Dominic Gannaway
ca46c5278f Move line to within DEV block (#10316)
* move line to within DEV block

* addressed code review feedback
2017-07-27 17:31:34 -07:00
Dan Abramov
c7e9044c51 Make it more specific 2017-07-27 23:44:43 +01:00
Fernando Montoya
95cec9927c Add Babel plugin note to Error boundaries post (#10313)
* Add Babel plugin note to Error boundaries post

* Added section with screenshots

* Add context to Component stack traces

* Update 2017-07-26-error-handling-in-react-16.md

* Move section, more minor changes

* Change pics
2017-07-27 23:25:59 +01:00
Dominic Gannaway
6b3b9b5563 Wraps two warnings that should be removed from PROD (#10315) 2017-07-27 11:24:34 -07:00
Nathan Hunzaker
083cc5f4f9 Add date time test fixtures (#10154)
* Add date time test fixtures

This commit adds a new section for the DOM test fixtures specifically
for date inputs. Additionally, it adds a test case to verify that
correct transference of dates between the `"date"` and
`"datetime-locale"` input types.

* Adjust date parsing to be clearer
2017-07-27 13:24:04 -04:00
Dan Abramov
138224f6b3 16.0.0-beta.2 2017-07-27 18:06:26 +01:00
Dan Abramov
7a60a80921 Make server hydration warnings more obviously about server (#10312) 2017-07-27 18:02:16 +01:00
Sebastian Markbåge
e1cfd6c082 Remove Error event listener eagerly instead of using depth count (#10296)
A little simpler.
2017-07-27 09:45:07 -07:00
Dan Abramov
44c74c7b12 Add smoke tests for styles (including SSR) (#10308)
* Add style to ReactDOM smoke test

* Add production smoke test for ReactDOMServer
2017-07-27 14:58:03 +01:00
Toru Kobayashi
69d07612c5 Add a link for the error boundaries codemod into the blog post (#10305)
* Add a link for the error boundaries codemod into the blog post

* Update 2017-07-26-error-handling-in-react-16.md
2017-07-27 14:57:33 +01:00
Dan Abramov
bc0d241be1 Reword further 2017-07-27 10:48:37 +01:00
Daniel Lo Nigro
759690f7b2 Replace "children (and grandchildren)" with "descendants" (#10297) 2017-07-27 10:23:36 +01:00
Keyan Zhang
3abbcc48a5 Fix ReactPartialRenderer in production (#10300) 2017-07-27 10:19:05 +01:00
Dominic Gannaway
f92343159d Wrap "warning" call in DEV block to prevent PROD error (#10295)
* re-adds warning module to FB PROD bundle

* Wrap the warning call too
2017-07-26 14:59:44 -07:00
Dan Abramov
1f3de403bc Link to React 16 beta 2017-07-26 21:20:12 +01:00
Dan Abramov
4ac21f2a5f Blog post: Error Handling in React 16 (#10267)
* Blog post: Error Handling in React 16

* Change the date
2017-07-26 21:15:19 +01:00
199 changed files with 4822 additions and 2407 deletions

View File

@@ -4,7 +4,7 @@
"plugins": [
"transform-class-properties",
"syntax-trailing-function-commas",
"transform-object-rest-spread",
["transform-object-rest-spread", { "useBuiltIns": true }],
"transform-es2015-template-literals",
"transform-es2015-literals",
"transform-es2015-arrow-functions",

View File

@@ -24,6 +24,7 @@ module.system=haste
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
unsafe.enable_getters_and_setters=true
munge_underscores=false

View File

@@ -9,7 +9,7 @@ Prior to this release, we stripped out error messages at build-time and this is
> Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.
In order to make debugging in production easier, we're introducing an Error Code System in [15.2.0](https://github.com/facebook/react/releases/tag/v15.2.0). We developed a [gulp script](https://github.com/facebook/react/blob/master/scripts/error-codes/gulp-extract-errors.js) that collects all of our `invariant` error messages and folds them to a [JSON file](https://github.com/facebook/react/blob/master/scripts/error-codes/codes.json), and at build-time Babel uses the JSON to [rewrite](https://github.com/facebook/react/blob/master/scripts/error-codes/dev-expression-with-codes.js) our `invariant` calls in production to reference the corresponding error IDs. Now when things go wrong in production, the error that React throws will contain a URL with an error ID and relevant information. The URL will point you to a page in our documentation where the original error message gets reassembled.
In order to make debugging in production easier, we're introducing an Error Code System in [15.2.0](https://github.com/facebook/react/releases/tag/v15.2.0). We developed a [gulp script](https://github.com/facebook/react/blob/master/scripts/error-codes/gulp-extract-errors.js) that collects all of our `invariant` error messages and folds them to a [JSON file](https://github.com/facebook/react/blob/master/scripts/error-codes/codes.json), and at build-time Babel uses the JSON to [rewrite](https://github.com/facebook/react/blob/master/scripts/error-codes/replace-invariant-error-codes.js) our `invariant` calls in production to reference the corresponding error IDs. Now when things go wrong in production, the error that React throws will contain a URL with an error ID and relevant information. The URL will point you to a page in our documentation where the original error message gets reassembled.
While we hope you don't see errors often, you can see how it works [here](/react/docs/error-decoder.html?invariant=109&args[]=Foo). This is what the same error from above will look like:

View File

@@ -0,0 +1,114 @@
---
title: "Error Handling in React 16"
author: gaearon
---
As React 16 release is getting closer, we would like to announce a few changes to how React handles JavaScript errors inside components. These changes are included in React 16 beta versions, and will be a part of React 16.
**By the way, [we just released the first beta of React 16 for you to try!](https://github.com/facebook/react/issues/10294)**
## Behavior in React 15 and Earlier
In the past, JavaScript errors inside components used to corrupt Reacts internal state and cause it to [emit](https://github.com/facebook/react/issues/4026) [cryptic](https://github.com/facebook/react/issues/6895) [errors](https://github.com/facebook/react/issues/8579) on next renders. These errors were always caused by an earlier error in the application code, but React did not provide a way to handle them gracefully in components, and could not recover from them.
## Introducing Error Boundaries
A JavaScript error in a part of the UI shouldnt break the whole app. To solve this problem for React users, React 16 introduces a new concept of an “error boundary”.
Error boundaries are React components that **catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI** instead of the component tree that crashed. Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them.
A class component becomes an error boundary if it defines a new lifecycle method called `componentDidCatch(error, info)`:
```js{7-12,15-18}
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
componentDidCatch(error, info) {
// Display fallback UI
this.setState({ hasError: true });
// You can also log the error to an error reporting service
logErrorToMyService(error, info);
}
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return <h1>Something went wrong.</h1>;
}
return this.props.children;
}
}
```
Then you can use it as a regular component:
```js
<ErrorBoundary>
<MyWidget />
</ErrorBoundary>
```
The `componentDidCatch()` method works like a JavaScript `catch {}` block, but for components. Only class components can be error boundaries. In practice, most of the time youll want to declare an error boundary component once and use it throughout your application.
Note that **error boundaries only catch errors in the components below them in the tree**. An error boundary cant catch an error within itself. If an error boundary fails trying to render the error message, the error will propagate to the closest error boundary above it. This, too, is similar to how `catch {}` block works in JavaScript.
## Live Demo
Check out [this example of declaring and using an error boundary](https://codepen.io/gaearon/pen/wqvxGa?editors=0010) with [React 16 beta](https://github.com/facebook/react/issues/10294).
## Where to Place Error Boundaries
The granularity of error boundaries is up to you. You may wrap top-level route components to display a “Something went wrong” message to the user, just like server-side frameworks often handle crashes. You may also wrap individual widgets in an error boundary to protect them from crashing the rest of the application.
## New Behavior for Uncaught Errors
This change has an important implication. **As of React 16, errors that were not caught by any error boundary will result in unmounting of the whole React component tree.**
We debated this decision, but in our experience it is worse to leave corrupted UI in place than to completely remove it. For example, in a product like Messenger leaving the broken UI visible could lead to somebody sending a message to the wrong person. Similarly, it is worse for a payments app to display a wrong amount than to render nothing.
This change means that as you migrate to React 16, you will likely uncover existing crashes in your application that have been unnoticed before. Adding error boundaries lets you provide better user experience when something goes wrong.
For example, Facebook Messenger wraps content of the sidebar, the info panel, the conversation log, and the message input into separate error boundaries. If some component in one of these UI areas crashes, the rest of them remain interactive.
We also encourage you to use JS error reporting services (or build your own) so that you can learn about unhandled exceptions as they happen in production, and fix them.
## Component Stack Traces
React 16 prints all errors that occurred during rendering to the console in development, even if the application accidentally swallows them. In addition to the error message and the JavaScript stack, it also provides component stack traces. Now you can see where exactly in the component tree the failure has happened:
<img src="/react/img/blog/error-boundaries-stack-trace.png" alt="Component stack traces in error message" style="width: 100%;">
You can also see the filenames and line numbers in the component stack trace. This works by default in [Create React App](https://github.com/facebookincubator/create-react-app) projects:
<img src="/react/img/blog/error-boundaries-stack-trace-line-numbers.png" alt="Component stack traces with line numbers in error message" style="width: 100%;">
If you dont use Create React App, you can add [this plugin](https://www.npmjs.com/package/babel-plugin-transform-react-jsx-source) manually to your Babel configuration. Note that its intended only for development and **must be disabled in production**.
## Why Not Use `try` / `catch`?
`try` / `catch` is great but it only works for imperative code:
```js
try {
showButton();
} catch (error) {
// ...
}
```
However, React components are declarative and specify *what* should be rendered:
```js
<Button />
```
Error boundaries preserve the declarative nature of React, and behave as you would expect. For example, even if an error occurs in a `componentDidUpdate` hook caused by a `setState` somewhere deep in the tree, it will still correctly propagate to the closest error boundary.
## Naming Changes from React 15
React 15 included a very limited support for error boundaries under a different method name: `unstable_handleError`. This method no longer works, and you will need to change it to `componentDidCatch` in your code starting from the first 16 beta release.
For this change, weve provided [a codemod](https://github.com/reactjs/react-codemod#error-boundaries) to automatically migrate your code.

View File

@@ -218,21 +218,35 @@ Learn [how to tell if your website is serving the right version of React](/react
If you don't want to use npm to manage client packages, the `react` and `react-dom` npm packages also provide single-file distributions in `dist` folders, which are hosted on a CDN:
```html
<script src="https://unpkg.com/react@15/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
<script crossorigin src="https://unpkg.com/react@15/dist/react.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
```
The versions above are only meant for development, and are not suitable for production. Minified and optimized production versions of React are available at:
```html
<script src="https://unpkg.com/react@15/dist/react.min.js"></script>
<script src="https://unpkg.com/react-dom@15/dist/react-dom.min.js"></script>
<script crossorigin src="https://unpkg.com/react@15/dist/react.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@15/dist/react-dom.min.js"></script>
```
To load a specific version of `react` and `react-dom`, replace `15` with the version number.
If you use Bower, React is available via the `react` package.
#### Why the `crossorigin` Attribute?
If you serve React from a CDN, we recommend to keep the [`crossorigin`](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) attribute set:
```html
<script crossorigin src="..."></script>
```
We also recommend to verify that the CDN you are using sets the `Access-Control-Allow-Origin: *` HTTP header:
![Access-Control-Allow-Origin: *](/react/img/docs/cdn-cors-header.png)
This enables a better [error handling experience](/react/blog/2017/07/26/error-handling-in-react-16.html) in React 16 and later.
<script>
/**
* The code below is based on a snippet from React Native Getting Started page.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 KiB

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 KiB

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 KiB

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 KiB

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 676 KiB

After

Width:  |  Height:  |  Size: 633 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 KiB

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 KiB

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -3,12 +3,13 @@
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "0.9.5"
"react-scripts": "1.0.0"
},
"dependencies": {
"classnames": "^2.2.5",
"query-string": "^4.2.3",
"core-js": "^2.4.1",
"prop-types": "^15.5.6",
"query-string": "^4.2.3",
"react": "^15.4.1",
"react-dom": "^15.4.1",
"semver": "^5.3.0"

View File

@@ -15,7 +15,7 @@
-->
<title>React App</title>
<script src="https://unpkg.com/prop-types@15.5.6/prop-types.js"></script>
<script src="react-loader.js"></script>
<script src="https://unpkg.com/expect@1.20.2/umd/expect.min.js"></script>
</head>
<body>
<div id="root"></div>

View File

@@ -1,43 +0,0 @@
/**
* Take a version from the window query string and load a specific
* version of React.
*
* @example
* http://localhost:3000?version=15.4.1
* (Loads React 15.4.1)
*/
var REACT_PATH = 'react.development.js';
var DOM_PATH = 'react-dom.development.js';
function parseQuery(qstr) {
var query = {};
var a = qstr.substr(1).split('&');
for (var i = 0; i < a.length; i++) {
var b = a[i].split('=');
query[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || '');
}
return query;
}
var query = parseQuery(window.location.search);
var version = query.version || 'local';
if (version !== 'local') {
REACT_PATH = 'https://unpkg.com/react@' + version + '/dist/react.js';
DOM_PATH = 'https://unpkg.com/react-dom@' + version + '/dist/react-dom.js';
}
document.write('<script src="' + REACT_PATH + '"></script>');
// Versions earlier than 14 do not use ReactDOM
if (version === 'local' || parseFloat(version, 10) > 0.13) {
document.write('<script src="' + DOM_PATH + '"></script>');
} else {
// Aliasing React to ReactDOM for compatibility.
document.write('<script>ReactDOM = React</script>');
}

View File

@@ -1,9 +1,9 @@
const React = window.React;
import Header from './Header';
import Fixtures from './fixtures';
import '../style.css';
const React = window.React;
function App() {
return (
<div>

View File

@@ -59,7 +59,9 @@ class Header extends React.Component {
Input change events
</option>
<option value="/buttons">Buttons</option>
<option value="/date-inputs">Date Inputs</option>
<option value="/error-handling">Error Handling</option>
<option value="/event-pooling">Event Pooling</option>
</select>
</label>
<label htmlFor="react_version">

View File

@@ -1,8 +1,8 @@
const React = window.React;
import FixtureSet from '../../FixtureSet';
import TestCase from '../../TestCase';
const React = window.React;
function onButtonClick() {
window.alert(`This shouldn't have happened!`);
}

Some files were not shown because too many files have changed in this diff Show More