From 35ebcd3c55483dab813a64fc25a5aa819ff736ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Tue, 7 Jun 2016 16:35:54 -0700 Subject: [PATCH] Rebuild website --- docs/error-decoder.html | 477 ++++++++++++++++++++++++++++++++++++ js/ErrorDecoderComponent.js | 139 +++++++++++ js/errorMap.js | 138 +++++++++++ 3 files changed, 754 insertions(+) create mode 100644 docs/error-decoder.html create mode 100644 js/ErrorDecoderComponent.js create mode 100644 js/errorMap.js diff --git a/docs/error-decoder.html b/docs/error-decoder.html new file mode 100644 index 0000000000..e7219b084c --- /dev/null +++ b/docs/error-decoder.html @@ -0,0 +1,477 @@ + + + + + + + Error Decoder | React + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + +
+ Edit on GitHub +

+ Error Decoder +

+
+ +

In the minified production build of React, we avoid sending down full error messages in order to reduce the number of bytes sent over the wire.

+ +

We highly recommend using the development build locally when debugging your app since it tracks additional debug info and provides helpful warnings about potential problems in your apps, but if you encounter an exception while using the production build, this page will reassemble the original text of the error.

+ + + +
+ + + + +
+ + +
+
+
+ + +
+
+ A Facebook & Instagram collaboration.
+ Acknowledgements +
+
+ © 2013–2016 Facebook Inc.
+ Documentation licensed under CC BY 4.0. +
+
+
+
+ + + + diff --git a/js/ErrorDecoderComponent.js b/js/ErrorDecoderComponent.js new file mode 100644 index 0000000000..643bff40c5 --- /dev/null +++ b/js/ErrorDecoderComponent.js @@ -0,0 +1,139 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +/* global React ReactDOM errorMap:true */ +'use strict'; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +function replaceArgs(msg, argList) { + var argIdx = 0; + return msg.replace(/%s/g, function () { + var arg = argList[argIdx++]; + return arg === undefined ? '[missing argument]' : arg; + }); +} + +function urlify(str) { + var urlRegex = /(https:\/\/fb\.me\/[a-z\-]+)/g; + + var segments = str.split(urlRegex); + + for (var i = 0; i < segments.length; i++) { + if (i % 2 === 1) { + segments[i] = React.createElement( + 'a', + { key: i, target: '_blank', href: segments[i] }, + segments[i] + ); + } + } + + return segments; +} + +// ?invariant=123&args[]=foo&args[]=bar +function parseQueryString() { + var rawQueryString = window.location.search.substring(1); + if (!rawQueryString) { + return null; + } + + var code = ''; + var args = []; + + var queries = rawQueryString.split('&'); + for (var i = 0; i < queries.length; i++) { + var query = decodeURIComponent(queries[i]); + if (query.indexOf('invariant=') === 0) { + code = query.slice(10); + } else if (query.indexOf('args[]=') === 0) { + args.push(query.slice(7)); + } + } + + return [code, args]; +} + +function ErrorResult(props) { + var code = props.code; + var errorMsg = props.msg; + + if (!code) { + return React.createElement( + 'p', + null, + 'When you encounter an error, you\'ll receive a link to this page for that specific error and we\'ll show you the full error text.' + ); + } + + return React.createElement( + 'div', + null, + React.createElement( + 'p', + null, + 'The full text of the error you just encountered is:' + ), + React.createElement( + 'code', + null, + urlify(errorMsg) + ) + ); +} + +var ErrorDecoder = function (_React$Component) { + _inherits(ErrorDecoder, _React$Component); + + function ErrorDecoder() { + _classCallCheck(this, ErrorDecoder); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var _this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))); + + _this.state = { + code: null, + errorMsg: '' + }; + return _this; + } + + ErrorDecoder.prototype.componentWillMount = function componentWillMount() { + var parseResult = parseQueryString(); + if (parseResult != null) { + var code = parseResult[0]; + var args = parseResult[1]; + + if (errorMap[code]) { + this.setState({ + code: code, + errorMsg: replaceArgs(errorMap[code], args) + }); + } + } + }; + + ErrorDecoder.prototype.render = function render() { + return React.createElement(ErrorResult, { + code: this.state.code, + msg: this.state.errorMsg + }); + }; + + return ErrorDecoder; +}(React.Component); + +ReactDOM.render(React.createElement(ErrorDecoder, null), document.querySelector('.error-decoder-container')); \ No newline at end of file diff --git a/js/errorMap.js b/js/errorMap.js new file mode 100644 index 0000000000..f7e1c699b0 --- /dev/null +++ b/js/errorMap.js @@ -0,0 +1,138 @@ +var errorMap = { + "0": "React.addons.createFragment(...): Encountered an invalid child; DOM elements are not valid children of React components.", + "1": "update(): expected target of %s to be an array; got %s.", + "2": "update(): expected spec of %s to be an array; got %s. Did you forget to wrap your parameter in an array?", + "3": "update(): You provided a key path to update() that did not contain one of %s. Did you forget to include {%s: ...}?", + "4": "Cannot have more than one key in an object with %s", + "5": "update(): %s expects a spec of type 'object'; got %s", + "6": "update(): %s expects a target of type 'object'; got %s", + "7": "Expected %s target to be an array; got %s", + "8": "update(): expected spec of %s to be an array of arrays; got %s. Did you forget to wrap your parameters in an array?", + "9": "update(): expected spec of %s to be a function; got %s.", + "10": "findAllInRenderedTree(...): instance must be a composite component", + "11": "TestUtils.scryRenderedDOMComponentsWithClass expects a className as a second argument.", + "12": "ReactShallowRenderer render(): Invalid component element.%s", + "13": "ReactShallowRenderer render(): Shallow rendering works only with custom components, not primitives (%s). Instead of calling `.render(el)` and inspecting the rendered output, look at `el.props` directly instead.", + "14": "TestUtils.Simulate expects a component instance and not a ReactElement.TestUtils.Simulate will not work if you are using shallow rendering.", + "15": "reactComponentExpect(...): instance must be a composite component", + "16": "Do not override existing functions.", + "17": "All native instances should have a tag.", + "18": "Expected a component class, got %s.%s", + "19": "Expect a native root tag, instead got %s", + "20": "RawText \"%s\" must be wrapped in an explicit component.", + "21": "findNodeHandle(...): Argument is not a component (type: %s, keys: %s)", + "22": "findNodeHandle(...): Unable to find node handle for unmounted component.", + "23": "onlyChild must be passed a children with exactly one child.", + "24": "Mismatched list of contexts in callback queue", + "25": "Trying to release an instance into a pool of a different type.", + "26": "Unexpected node: %s", + "27": "Transaction.perform(...): Cannot initialize a transaction when there is already an outstanding transaction.", + "28": "Transaction.closeAll(): Cannot close transaction when none are open.", + "29": "accumulate(...): Accumulated items must be not be null or undefined.", + "30": "accumulateInto(...): Accumulated items must not be null or undefined.", + "31": "Objects are not valid as a React child (found: %s).%s", + "32": "Unable to find element with ID %s.", + "33": "getNodeFromInstance: Invalid argument.", + "34": "React DOM tree root should always have a node reference.", + "35": "isAncestor: Invalid argument.", + "36": "getParentInstance: Invalid argument.", + "37": "_registerComponent(...): Target container is not a DOM element.", + "38": "parentComponent must be a valid React Component", + "39": "ReactDOM.render(): Invalid component element.%s", + "40": "unmountComponentAtNode(...): Target container is not a DOM element.", + "41": "mountComponentIntoNode(...): Target container is not valid.", + "42": "You're trying to render a component to the document using server rendering but the checksum was invalid. This usually means you rendered a different component type or props on the client from the one on the server, or your render() methods are impure. React cannot handle this case due to cross-browser quirks by rendering at the document root. You should look for environment dependent code in your components and ensure the props are the same client and server side:\n%s", + "43": "You're trying to render a component to the document but you didn't use server rendering. We can't do this without using server rendering due to cross-browser quirks. See ReactDOMServer.renderToString() for server rendering.", + "44": "findDOMNode was called on an unmounted component.", + "45": "Element appears to be neither ReactComponent nor DOMNode (keys: %s)", + "46": "renderToString(): You must pass a valid ReactElement.", + "47": "renderToStaticMarkup(): You must pass a valid ReactElement.", + "48": "injectDOMPropertyConfig(...): You're trying to inject DOM property '%s' which has already been injected. You may be accidentally injecting the same DOM property config twice, or you may be injecting two configs that have conflicting property names.", + "49": "DOMProperty: Properties that have side effects must use property: %s", + "50": "DOMProperty: Value can be one of boolean, overloaded boolean, or numeric value, but not a combination: %s", + "51": "dangerouslyRenderMarkup(...): Cannot render markup in a worker thread. Make sure `window` and `document` are available globally before requiring React when unit testing or use ReactDOMServer.renderToString for server rendering.", + "52": "dangerouslyRenderMarkup(...): Missing markup.", + "53": "Danger: Assigning to an already-occupied result index.", + "54": "Danger: Did not assign to every index of resultList.", + "55": "Danger: Expected markup to render %s nodes, but rendered %s.", + "56": "dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a worker thread. Make sure `window` and `document` are available globally before requiring React when unit testing or use ReactDOMServer.renderToString() for server rendering.", + "57": "dangerouslyReplaceNodeWithMarkup(...): Missing markup.", + "58": "dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the node. This is because browser quirks make this unreliable and/or slow. If you want to render to the root you must use server rendering. See ReactDOMServer.renderToString().", + "59": "%s is a void element tag and must not have `children` or use `props.dangerouslySetInnerHTML`.%s", + "60": "Can only set one of `children` or `props.dangerouslySetInnerHTML`.", + "61": "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.", + "62": "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX.%s", + "63": "Must be mounted to trap events", + "64": "trapBubbledEvent(...): Requires node to be rendered.", + "65": "Invalid tag: %s", + "66": "<%s> tried to unmount. Because of cross-browser quirks it is impossible to unmount some top-level components (eg , , and ) reliably and efficiently. To fix this, have a single top-level component that never unmounts render these elements.", + "67": "Missing closing comment for text component %s", + "68": "Expected devtool events to fire for the child before its parent includes it in onSetChildren().", + "69": "Expected onSetDisplayName() to fire for the child before its parent includes it in onSetChildren().", + "70": "Expected onSetChildren() or onSetText() to fire for the child before its parent includes it in onSetChildren().", + "71": "Expected onMountComponent() to fire for the child before its parent includes it in onSetChildren().", + "72": "Expected onSetParent() and onSetChildren() to be consistent (%s has parents %s and %s).", + "73": "ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.", + "74": "ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.", + "75": "ReactClass: You're attempting to use a component class or function as a mixin. Instead, just use a regular object.", + "76": "ReactClass: You're attempting to use a component as a mixin. Instead, just use a regular object.", + "77": "ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.", + "78": "ReactClass: You are attempting to define a reserved property, `%s`, that shouldn't be on the \"statics\" key. Define it as an instance property instead; it will still be accessible on the constructor.", + "79": "ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.", + "80": "mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.", + "81": "mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.", + "82": "%s.getInitialState(): must return an object or null", + "83": "createClass(...): Class specification must implement a `render` method.", + "84": "%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.", + "85": "setState(...): takes an object of state variables to update or a function which returns an object of state variables.", + "86": "SimpleEventPlugin: Unhandled event type, `%s`.", + "87": "Cannot provide a checkedLink and a valueLink. If you want to use checkedLink, you probably don't want to use valueLink and vice versa.", + "88": "Cannot provide a valueLink and a value or onChange event. If you want to use value or onChange, you probably don't want to use valueLink.", + "89": "Cannot provide a checkedLink and a checked property or onChange event. If you want to use checked or onChange, you probably don't want to use checkedLink", + "90": "ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported.", + "91": "`dangerouslySetInnerHTML` does not make sense on