UNPKG

11.3 kBJavaScriptView Raw
1/** @license React v16.8.0
2 * react-test-renderer-shallow.production.min.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9'use strict';(function(k,l){"object"===typeof exports&&"undefined"!==typeof module?module.exports=l(require("react")):"function"===typeof define&&define.amd?define(["react"],l):k.ReactShallowRenderer=l(k.React)})(this,function(k){function l(a,b,d,c,e,A,f,h){if(!a){a=void 0;if(void 0===b)a=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var g=[d,c,e,A,f,h],B=0;a=Error(b.replace(/%s/g,function(){return g[B++]}));
10a.name="Invariant Violation"}a.framesToPop=1;throw a;}}function m(a){for(var b=arguments.length-1,d="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=0;c<b;c++)d+="&args[]="+encodeURIComponent(arguments[c+1]);l(!1,"Minified React error #"+a+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",d)}function v(a){if("object"===typeof a&&null!==a){var b=a.$$typeof;switch(b){case C:switch(a=a.type,a){case D:case E:case F:case G:case H:case I:return a;
11default:switch(a=a&&a.$$typeof,a){case J:case q:case K:return a;default:return b}}case L:case M:case N:return b}}}function r(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}function w(a,b){if(r(a,b))return!0;if("object"!==typeof a||null===a||"object"!==typeof b||null===b)return!1;var d=Object.keys(a),c=Object.keys(b);if(d.length!==c.length)return!1;for(c=0;c<d.length;c++)if(!O.call(b,d[c])||!r(a[d[c]],b[d[c]]))return!1;return!0}function x(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");
12}function y(){return{memoizedState:null,queue:null,next:null}}function z(a,b){return"function"===typeof b?b(a):b}var t=k.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.assign,f="function"===typeof Symbol&&Symbol.for,C=f?Symbol.for("react.element"):60103,N=f?Symbol.for("react.portal"):60106,F=f?Symbol.for("react.fragment"):60107,H=f?Symbol.for("react.strict_mode"):60108,G=f?Symbol.for("react.profiler"):60114,K=f?Symbol.for("react.provider"):60109,J=f?Symbol.for("react.context"):60110,D=f?Symbol.for("react.async_mode"):
1360111,E=f?Symbol.for("react.concurrent_mode"):60111,q=f?Symbol.for("react.forward_ref"):60112,I=f?Symbol.for("react.suspense"):60113,M=f?Symbol.for("react.memo"):60115,L=f?Symbol.for("react.lazy"):60116,O=Object.prototype.hasOwnProperty,u=k.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher,n={},P=function(){function a(b){x(this,a);this._renderer=b;this._callbacks=[]}a.prototype._enqueueCallback=function(b,a){"function"===typeof b&&a&&this._callbacks.push({callback:b,publicInstance:a})};
14a.prototype._invokeCallbacks=function(){var b=this._callbacks;this._callbacks=[];b.forEach(function(b){b.callback.call(b.publicInstance)})};a.prototype.isMounted=function(b){return!!this._renderer._element};a.prototype.enqueueForceUpdate=function(b,a,c){this._enqueueCallback(a,b);this._renderer._forcedUpdate=!0;this._renderer.render(this._renderer._element,this._renderer._context)};a.prototype.enqueueReplaceState=function(b,a,c,e){this._enqueueCallback(c,b);this._renderer._newState=a;this._renderer.render(this._renderer._element,
15this._renderer._context)};a.prototype.enqueueSetState=function(b,a,c,e){this._enqueueCallback(c,b);c=this._renderer._newState||b.state;"function"===typeof a&&(a=a.call(b,c,b.props));null!==a&&void 0!==a&&(this._renderer._newState=t({},c,a),this._renderer.render(this._renderer._element,this._renderer._context))};return a}(),p=function(){function a(){x(this,a);this._rendered=this._newState=this._instance=this._element=this._context=null;this._forcedUpdate=this._rendering=!1;this._updater=new P(this);
16this._dispatcher=this._createDispatcher();this._firstWorkInProgressHook=this._workInProgressHook=null;this._didScheduleRenderPhaseUpdate=this._isReRender=!1;this._currentlyRenderingComponent=this._renderPhaseUpdates=null;this._numberOfReRenders=0;this._previousComponentIdentity=null}a.prototype._validateCurrentlyRenderingComponent=function(){null===this._currentlyRenderingComponent?m("307"):void 0};a.prototype._createDispatcher=function(){var b=this,a=function(a,c,d){b._validateCurrentlyRenderingComponent();
17b._createWorkInProgressHook();var e=b._workInProgressHook;if(b._isReRender){var g=e.queue;c=g.dispatch;if(null!==b._renderPhaseUpdates&&(d=b._renderPhaseUpdates.get(g),void 0!==d)){b._renderPhaseUpdates.delete(g);g=e.memoizedState;do g=a(g,d.action),d=d.next;while(null!==d);e.memoizedState=g;return[g,c]}return[e.memoizedState,c]}a=a===z?"function"===typeof c?c():c:void 0!==d?d(c):c;e.memoizedState=a;a=e.queue={last:null,dispatch:null};a=a.dispatch=b._dispatchAction.bind(b,b._currentlyRenderingComponent,
18a);return[e.memoizedState,a]},c=function(){b._validateCurrentlyRenderingComponent()};return{readContext:function(b,a){return b._currentValue},useCallback:function(b){return b},useContext:function(a){b._validateCurrentlyRenderingComponent();return a._currentValue},useDebugValue:c,useEffect:c,useImperativeHandle:c,useLayoutEffect:c,useMemo:function(a,c){b._validateCurrentlyRenderingComponent();b._createWorkInProgressHook();c=void 0!==c?c:null;if(null!==b._workInProgressHook&&null!==b._workInProgressHook.memoizedState){var d=
19b._workInProgressHook.memoizedState,e=d[1];if(null!==c){a:if(null===e)e=!1;else{for(var g=0;g<e.length&&g<c.length;g++)if(!r(c[g],e[g])){e=!1;break a}e=!0}if(e)return d[0]}}a=a();b._workInProgressHook.memoizedState=[a,c];return a},useReducer:a,useRef:function(a){b._validateCurrentlyRenderingComponent();b._createWorkInProgressHook();var c=b._workInProgressHook.memoizedState;return null===c?(a={current:a},b._workInProgressHook.memoizedState=a):c},useState:function(b){return a(z,b)}}};a.prototype._dispatchAction=
20function(b,a,c){25>this._numberOfReRenders?void 0:m("301");if(b===this._currentlyRenderingComponent){this._didScheduleRenderPhaseUpdate=!0;b={action:c,next:null};c=this._renderPhaseUpdates;null===c&&(this._renderPhaseUpdates=c=new Map);var d=c.get(a);if(void 0===d)c.set(a,b);else{for(a=d;null!==a.next;)a=a.next;a.next=b}}};a.prototype._createWorkInProgressHook=function(){null===this._workInProgressHook?null===this._firstWorkInProgressHook?(this._isReRender=!1,this._firstWorkInProgressHook=this._workInProgressHook=
21y()):(this._isReRender=!0,this._workInProgressHook=this._firstWorkInProgressHook):null===this._workInProgressHook.next?(this._isReRender=!1,this._workInProgressHook=this._workInProgressHook.next=y()):(this._isReRender=!0,this._workInProgressHook=this._workInProgressHook.next);return this._workInProgressHook};a.prototype._prepareToUseHooks=function(b){null!==this._previousComponentIdentity&&this._previousComponentIdentity!==b&&(this._firstWorkInProgressHook=null);this._previousComponentIdentity=this._currentlyRenderingComponent=
22b};a.prototype._finishHooks=function(b,a){this._didScheduleRenderPhaseUpdate?(this._didScheduleRenderPhaseUpdate=!1,this._numberOfReRenders+=1,this._workInProgressHook=null,this._rendering=!1,this.render(b,a)):(this._renderPhaseUpdates=this._workInProgressHook=this._currentlyRenderingComponent=null,this._numberOfReRenders=0)};a.prototype.getMountedInstance=function(){return this._instance};a.prototype.getRenderOutput=function(){return this._rendered};a.prototype.render=function(b){var a=1<arguments.length&&
23void 0!==arguments[1]?arguments[1]:n;k.isValidElement(b)?void 0:m("12","function"===typeof b?" Instead of passing a component class, make sure to instantiate it by passing it to React.createElement.":"");"string"===typeof b.type?m("13",b.type):void 0;v(b)!==q&&"function"!==typeof b.type?m("249",Array.isArray(b.type)?"array":null===b.type?"null":typeof b.type):void 0;if(!this._rendering){this._rendering=!0;this._element=b;var c;if((c=b.type.contextTypes)&&a){var e={},f;for(f in c)e[f]=a[f];c=e}else c=
24n;this._context=c;if(this._instance)this._updateClassComponent(b,this._context);else if(v(b)===q)this._rendered=b.type.render(b.props,b.ref);else if(c=b.type,c.prototype&&c.prototype.isReactComponent)this._instance=new b.type(b.props,this._context,this._updater),"function"===typeof b.type.getDerivedStateFromProps&&(a=b.type.getDerivedStateFromProps.call(null,b.props,this._instance.state),null!=a&&(this._instance.state=t({},this._instance.state,a))),b.type.hasOwnProperty("contextTypes"),this._mountClassComponent(b,
25this._context);else{c=u.current;u.current=this._dispatcher;this._prepareToUseHooks(b.type);try{this._rendered=b.type.call(void 0,b.props,this._context)}finally{u.current=c}this._finishHooks(b,a)}this._rendering=!1;this._updater._invokeCallbacks();return this.getRenderOutput()}};a.prototype.unmount=function(){this._instance&&"function"===typeof this._instance.componentWillUnmount&&this._instance.componentWillUnmount();this._instance=this._rendered=this._newState=this._element=this._context=this._previousComponentIdentity=
26this._firstWorkInProgressHook=null};a.prototype._mountClassComponent=function(b,a){this._instance.context=a;this._instance.props=b.props;this._instance.state=this._instance.state||null;this._instance.updater=this._updater;if("function"===typeof this._instance.UNSAFE_componentWillMount||"function"===typeof this._instance.componentWillMount)a=this._newState,"function"!==typeof b.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillMount&&
27this._instance.componentWillMount(),"function"===typeof this._instance.UNSAFE_componentWillMount&&this._instance.UNSAFE_componentWillMount()),a!==this._newState&&(this._instance.state=this._newState||n);this._rendered=this._instance.render()};a.prototype._updateClassComponent=function(a,d){var b=a.props,e=a.type,f=this._instance.state||n,k=this._instance.props;k!==b&&"function"!==typeof a.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillReceiveProps&&
28this._instance.componentWillReceiveProps(b,d),"function"===typeof this._instance.UNSAFE_componentWillReceiveProps&&this._instance.UNSAFE_componentWillReceiveProps(b,d));var h=this._newState||f;if("function"===typeof e.getDerivedStateFromProps){var g=e.getDerivedStateFromProps.call(null,b,h);null!=g&&(h=t({},h,g))}g=!0;this._forcedUpdate?(g=!0,this._forcedUpdate=!1):"function"===typeof this._instance.shouldComponentUpdate?g=!!this._instance.shouldComponentUpdate(b,h,d):e.prototype&&e.prototype.isPureReactComponent&&
29(g=!w(k,b)||!w(f,h));g&&"function"!==typeof a.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillUpdate&&this._instance.componentWillUpdate(b,h,d),"function"===typeof this._instance.UNSAFE_componentWillUpdate&&this._instance.UNSAFE_componentWillUpdate(b,h,d));this._instance.context=d;this._instance.props=b;this._instance.state=h;this._newState=null;g&&(this._rendered=this._instance.render())};return a}();p.createRenderer=
30function(){return new p};f=(f={default:p},p)||f;return f.default||f});