mobx-react
Advanced tools
Comparing version 7.2.0 to 7.2.1
# mobx-react | ||
## 7.2.1 | ||
### Patch Changes | ||
- [`8a1ff856`](https://github.com/mobxjs/mobx/commit/8a1ff856043d59396f623f8ca209822b1331d85f) [#3103](https://github.com/mobxjs/mobx/pull/3103) Thanks [@urugator](https://github.com/urugator)! - Missing `render` on component prototype throws. | ||
## 7.2.0 | ||
@@ -4,0 +10,0 @@ |
@@ -232,2 +232,8 @@ 'use strict'; | ||
if (typeof baseRender !== 'function') { | ||
var _displayName = getDisplayName(target); | ||
throw new Error("[mobx-react] class component (" + _displayName + ") is missing `render` method." + "\n`observer` requires `render` being a function defined on prototype." + "\n`render = () => {}` or `render = function() {}` is not supported."); | ||
} | ||
target.render = function () { | ||
@@ -246,5 +252,5 @@ return makeComponentReactive.call(this, baseRender); | ||
// Render may have been hot-swapped and/or overriden by a subclass. | ||
var _displayName = getDisplayName(this); | ||
var _displayName2 = getDisplayName(this); | ||
console.warn("The reactive render of an observer class component (" + _displayName + ") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed."); | ||
console.warn("The reactive render of an observer class component (" + _displayName2 + ") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed."); | ||
} | ||
@@ -251,0 +257,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("mobx"),t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,o=require("mobx-react-lite"),a=0,i={};function s(e){return i[e]||(i[e]=function(e){if("function"==typeof Symbol)return Symbol(e);var r="__$mobx-react "+e+" ("+a+")";return a++,r}(e)),i[e]}function c(e,r){if(u(e,r))return!0;if("object"!=typeof e||null===e||"object"!=typeof r||null===r)return!1;var t=Object.keys(e),n=Object.keys(r);if(t.length!==n.length)return!1;for(var o=0;o<t.length;o++)if(!Object.hasOwnProperty.call(r,t[o])||!u(e[t[o]],r[t[o]]))return!1;return!0}function u(e,r){return e===r?0!==e||1/e==1/r:e!=e&&r!=r}var l={$$typeof:1,render:1,compare:1,type:1,childContextTypes:1,contextType:1,contextTypes:1,defaultProps:1,getDefaultProps:1,getDerivedStateFromError:1,getDerivedStateFromProps:1,mixins:1,displayName:1,propTypes:1};function f(e,r,t){Object.hasOwnProperty.call(e,r)?e[r]=t:Object.defineProperty(e,r,{enumerable:!1,configurable:!0,writable:!0,value:t})}var p=s("patchMixins"),b=s("patchedDefinition");function d(e,r){for(var t=this,n=arguments.length,o=new Array(n>2?n-2:0),a=2;a<n;a++)o[a-2]=arguments[a];r.locks++;try{var i;return null!=e&&(i=e.apply(this,o)),i}finally{r.locks--,0===r.locks&&r.methods.forEach((function(e){e.apply(t,o)}))}}function y(e,r){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];d.call.apply(d,[this,e,r].concat(n))}}function v(e,r,t){var n=function(e,r){var t=e[p]=e[p]||{},n=t[r]=t[r]||{};return n.locks=n.locks||0,n.methods=n.methods||[],n}(e,r);n.methods.indexOf(t)<0&&n.methods.push(t);var o=Object.getOwnPropertyDescriptor(e,r);if(!o||!o[b]){var a=function e(r,t,n,o,a){var i,s=y(a,o);return(i={})[b]=!0,i.get=function(){return s},i.set=function(a){if(this===r)s=y(a,o);else{var i=e(this,t,n,o,a);Object.defineProperty(this,t,i)}},i.configurable=!0,i.enumerable=n,i}(e,r,o?o.enumerable:void 0,n,e[r]);Object.defineProperty(e,r,a)}}var m=r.$mobx||"$mobx",h=s("isMobXReactObserver"),O=s("isUnmounted"),g=s("skipRender"),w=s("isForcingUpdate");function j(e){var r=e.prototype;if(e[h]){var n=x(r);console.warn("The provided component class ("+n+") \n has already been declared as an observer component.")}else e[h]=!0;if(r.componentWillReact)throw new Error("The componentWillReact life-cycle event is no longer supported");if(e.__proto__!==t.PureComponent)if(r.shouldComponentUpdate){if(r.shouldComponentUpdate!==R)throw new Error("It is not allowed to use shouldComponentUpdate in observer based components.")}else r.shouldComponentUpdate=R;S(r,"props"),S(r,"state");var a=r.render;return r.render=function(){return P.call(this,a)},v(r,"componentWillUnmount",(function(){var e;if(!0!==o.isUsingStaticRendering()&&(null==(e=this.render[m])||e.dispose(),this[O]=!0,!this.render[m])){var r=x(this);console.warn("The reactive render of an observer class component ("+r+") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed.")}})),e}function x(e){return e.displayName||e.name||e.constructor&&(e.constructor.displayName||e.constructor.name)||"<component>"}function P(e){var n=this;if(!0===o.isUsingStaticRendering())return e.call(this);f(this,g,!1),f(this,w,!1);var a=x(this),i=e.bind(this),s=!1,c=new r.Reaction(a+".render()",(function(){if(!s&&(s=!0,!0!==n[O])){var e=!0;try{f(n,w,!0),n[g]||t.Component.prototype.forceUpdate.call(n),e=!1}finally{f(n,w,!1),e&&c.dispose()}}}));function u(){s=!1;var e=void 0,t=void 0;if(c.track((function(){try{t=r._allowStateChanges(!1,i)}catch(r){e=r}})),e)throw e;return t}return c.reactComponent=this,u[m]=c,this.render=u,u.call(this)}function R(e,r){return o.isUsingStaticRendering()&&console.warn("[mobx-react] It seems that a re-rendering of a React component is triggered while in static (server-side) mode. Please make sure components are rendered only once server-side."),this.state!==r||!c(this.props,e)}function S(e,t){var n=s("reactProp_"+t+"_valueHolder"),o=s("reactProp_"+t+"_atomHolder");function a(){return this[o]||f(this,o,r.createAtom("reactive "+t)),this[o]}Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){var e=!1;return r._allowStateReadsStart&&r._allowStateReadsEnd&&(e=r._allowStateReadsStart(!0)),a.call(this).reportObserved(),r._allowStateReadsStart&&r._allowStateReadsEnd&&r._allowStateReadsEnd(e),this[n]},set:function(e){this[w]||c(this[n],e)?f(this,n,e):(f(this,n,e),f(this,g,!0),a.call(this).reportChanged(),f(this,g,!1))}})}var C="function"==typeof Symbol&&Symbol.for,E=C?Symbol.for("react.forward_ref"):"function"==typeof t.forwardRef&&t.forwardRef((function(e){return null})).$$typeof,A=C?Symbol.for("react.memo"):"function"==typeof t.memo&&t.memo((function(e){return null})).$$typeof;function k(e){if(!0===e.isMobxInjector&&console.warn("Mobx observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'"),A&&e.$$typeof===A)throw new Error("Mobx observer: You are trying to use 'observer' on a function component wrapped in either another observer or 'React.memo'. The observer already applies 'React.memo' for you.");if(E&&e.$$typeof===E){var r=e.render;if("function"!=typeof r)throw new Error("render property of ForwardRef was not a function");return t.forwardRef((function(){var e=arguments;return t.createElement(o.Observer,null,(function(){return r.apply(void 0,e)}))}))}return"function"!=typeof e||e.prototype&&e.prototype.render||e.isReactClass||Object.prototype.isPrototypeOf.call(t.Component,e)?j(e):o.observer(e)}function U(){return(U=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var _=n.createContext({});function M(e){var r=e.children,t=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r.indexOf(t=a[n])>=0||(o[t]=e[t]);return o}(e,["children"]),o=n.useContext(_),a=n.useRef(U({},o,t));return n.createElement(_.Provider,{value:a.current},r)}function T(e,r,t,o){var a,i,s,c=n.forwardRef((function(t,o){var a=U({},t),i=n.useContext(_);return Object.assign(a,e(i||{},a)||{}),o&&(a.ref=o),n.createElement(r,a)}));return o&&(c=k(c)),c.isMobxInjector=!0,a=r,i=c,s=Object.getOwnPropertyNames(Object.getPrototypeOf(a)),Object.getOwnPropertyNames(a).forEach((function(e){l[e]||-1!==s.indexOf(e)||Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))})),c.wrappedComponent=r,c.displayName=function(e,r){var t=e.displayName||e.name||e.constructor&&e.constructor.name||"Component";return r?"inject-with-"+r+"("+t+")":"inject("+t+")"}(r,t),c}function $(e){return function(r,t){return e.forEach((function(e){if(!(e in t)){if(!(e in r))throw new Error("MobX injector: Store '"+e+"' is not available! Make sure it is provided by some Provider");t[e]=r[e]}})),t}}M.displayName="MobXProvider";var N=s("disposeOnUnmountProto"),q=s("disposeOnUnmountInst");function D(){var e=this;[].concat(this[N]||[],this[q]||[]).forEach((function(r){var t="string"==typeof r?e[r]:r;null!=t&&(Array.isArray(t)?t.map((function(e){return e()})):t())}))}function I(e){function t(t,n,o,a,i,s){for(var c=arguments.length,u=new Array(c>6?c-6:0),l=6;l<c;l++)u[l-6]=arguments[l];return r.untracked((function(){return a=a||"<<anonymous>>",s=s||o,null==n[o]?t?new Error("The "+i+" `"+s+"` is marked as required in `"+a+"`, but its value is `"+(null===n[o]?"null":"undefined")+"`."):null:e.apply(void 0,[n,o,a,i,s].concat(u))}))}var n=t.bind(null,!1);return n.isRequired=t.bind(null,!0),n}function L(e){var r=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,r){return"symbol"===e||"Symbol"===r["@@toStringTag"]||"function"==typeof Symbol&&r instanceof Symbol}(r,e)?"symbol":r}function X(e,t){return I((function(n,o,a,i,s){return r.untracked((function(){if(e&&L(n[o])===t.toLowerCase())return null;var i;switch(t){case"Array":i=r.isObservableArray;break;case"Object":i=r.isObservableObject;break;case"Map":i=r.isObservableMap;break;default:throw new Error("Unexpected mobxType: "+t)}var c=n[o];if(!i(c)){var u=function(e){var r=L(e);if("object"===r){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return r}(c),l=e?" or javascript `"+t.toLowerCase()+"`":"";return new Error("Invalid prop `"+s+"` of type `"+u+"` supplied to `"+a+"`, expected `mobx.Observable"+t+"`"+l+".")}return null}))}))}function F(e,t){return I((function(n,o,a,i,s){for(var c=arguments.length,u=new Array(c>5?c-5:0),l=5;l<c;l++)u[l-5]=arguments[l];return r.untracked((function(){if("function"!=typeof t)return new Error("Property `"+s+"` of component `"+a+"` has invalid PropType notation.");var r=X(e,"Array")(n,o,a,i,s);if(r instanceof Error)return r;for(var c=n[o],l=0;l<c.length;l++)if((r=t.apply(void 0,[c,l,a,i,s+"["+l+"]"].concat(u)))instanceof Error)return r;return null}))}))}var W={observableArray:X(!1,"Array"),observableArrayOf:F.bind(null,!1),observableMap:X(!1,"Map"),observableObject:X(!1,"Object"),arrayOrObservableArray:X(!0,"Array"),arrayOrObservableArrayOf:F.bind(null,!0),objectOrObservableObject:X(!0,"Object")};if(!t.Component)throw new Error("mobx-react requires React to be available");if(!r.observable)throw new Error("mobx-react requires mobx to be available");Object.defineProperty(exports,"Observer",{enumerable:!0,get:function(){return o.Observer}}),Object.defineProperty(exports,"enableStaticRendering",{enumerable:!0,get:function(){return o.enableStaticRendering}}),Object.defineProperty(exports,"isUsingStaticRendering",{enumerable:!0,get:function(){return o.isUsingStaticRendering}}),Object.defineProperty(exports,"observerBatching",{enumerable:!0,get:function(){return o.observerBatching}}),Object.defineProperty(exports,"useAsObservableSource",{enumerable:!0,get:function(){return o.useAsObservableSource}}),Object.defineProperty(exports,"useLocalObservable",{enumerable:!0,get:function(){return o.useLocalObservable}}),Object.defineProperty(exports,"useLocalStore",{enumerable:!0,get:function(){return o.useLocalStore}}),Object.defineProperty(exports,"useObserver",{enumerable:!0,get:function(){return o.useObserver}}),Object.defineProperty(exports,"useStaticRendering",{enumerable:!0,get:function(){return o.useStaticRendering}}),exports.MobXProviderContext=_,exports.PropTypes=W,exports.Provider=M,exports.disposeOnUnmount=function e(r,t){if(Array.isArray(t))return t.map((function(t){return e(r,t)}));var o=Object.getPrototypeOf(r).constructor,a=Object.getPrototypeOf(r.constructor),i=Object.getPrototypeOf(Object.getPrototypeOf(r));if(o!==n.Component&&o!==n.PureComponent&&a!==n.Component&&a!==n.PureComponent&&i!==n.Component&&i!==n.PureComponent)throw new Error("[mobx-react] disposeOnUnmount only supports direct subclasses of React.Component or React.PureComponent.");if("string"!=typeof t&&"function"!=typeof t&&!Array.isArray(t))throw new Error("[mobx-react] disposeOnUnmount only works if the parameter is either a property key or a function.");var s=!!r[N]||!!r[q];return("string"==typeof t?r[N]||(r[N]=[]):r[q]||(r[q]=[])).push(t),s||v(r,"componentWillUnmount",D),"string"!=typeof t?t:void 0},exports.inject=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];if("function"==typeof arguments[0]){var n=arguments[0];return function(e){return T(n,e,n.name,!0)}}return function(e){return T($(r),e,r.join("-"),!1)}},exports.observer=k; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("mobx"),t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,o=require("mobx-react-lite"),a=0,i={};function s(e){return i[e]||(i[e]=function(e){if("function"==typeof Symbol)return Symbol(e);var r="__$mobx-react "+e+" ("+a+")";return a++,r}(e)),i[e]}function c(e,r){if(u(e,r))return!0;if("object"!=typeof e||null===e||"object"!=typeof r||null===r)return!1;var t=Object.keys(e),n=Object.keys(r);if(t.length!==n.length)return!1;for(var o=0;o<t.length;o++)if(!Object.hasOwnProperty.call(r,t[o])||!u(e[t[o]],r[t[o]]))return!1;return!0}function u(e,r){return e===r?0!==e||1/e==1/r:e!=e&&r!=r}var f={$$typeof:1,render:1,compare:1,type:1,childContextTypes:1,contextType:1,contextTypes:1,defaultProps:1,getDefaultProps:1,getDerivedStateFromError:1,getDerivedStateFromProps:1,mixins:1,displayName:1,propTypes:1};function l(e,r,t){Object.hasOwnProperty.call(e,r)?e[r]=t:Object.defineProperty(e,r,{enumerable:!1,configurable:!0,writable:!0,value:t})}var p=s("patchMixins"),b=s("patchedDefinition");function d(e,r){for(var t=this,n=arguments.length,o=new Array(n>2?n-2:0),a=2;a<n;a++)o[a-2]=arguments[a];r.locks++;try{var i;return null!=e&&(i=e.apply(this,o)),i}finally{r.locks--,0===r.locks&&r.methods.forEach((function(e){e.apply(t,o)}))}}function y(e,r){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];d.call.apply(d,[this,e,r].concat(n))}}function m(e,r,t){var n=function(e,r){var t=e[p]=e[p]||{},n=t[r]=t[r]||{};return n.locks=n.locks||0,n.methods=n.methods||[],n}(e,r);n.methods.indexOf(t)<0&&n.methods.push(t);var o=Object.getOwnPropertyDescriptor(e,r);if(!o||!o[b]){var a=function e(r,t,n,o,a){var i,s=y(a,o);return(i={})[b]=!0,i.get=function(){return s},i.set=function(a){if(this===r)s=y(a,o);else{var i=e(this,t,n,o,a);Object.defineProperty(this,t,i)}},i.configurable=!0,i.enumerable=n,i}(e,r,o?o.enumerable:void 0,n,e[r]);Object.defineProperty(e,r,a)}}var v=r.$mobx||"$mobx",h=s("isMobXReactObserver"),O=s("isUnmounted"),g=s("skipRender"),w=s("isForcingUpdate");function j(e){var r=e.prototype;if(e[h]){var n=x(r);console.warn("The provided component class ("+n+") \n has already been declared as an observer component.")}else e[h]=!0;if(r.componentWillReact)throw new Error("The componentWillReact life-cycle event is no longer supported");if(e.__proto__!==t.PureComponent)if(r.shouldComponentUpdate){if(r.shouldComponentUpdate!==R)throw new Error("It is not allowed to use shouldComponentUpdate in observer based components.")}else r.shouldComponentUpdate=R;S(r,"props"),S(r,"state");var a=r.render;if("function"!=typeof a){var i=x(r);throw new Error("[mobx-react] class component ("+i+") is missing `render` method.\n`observer` requires `render` being a function defined on prototype.\n`render = () => {}` or `render = function() {}` is not supported.")}return r.render=function(){return P.call(this,a)},m(r,"componentWillUnmount",(function(){var e;if(!0!==o.isUsingStaticRendering()&&(null==(e=this.render[v])||e.dispose(),this[O]=!0,!this.render[v])){var r=x(this);console.warn("The reactive render of an observer class component ("+r+") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed.")}})),e}function x(e){return e.displayName||e.name||e.constructor&&(e.constructor.displayName||e.constructor.name)||"<component>"}function P(e){var n=this;if(!0===o.isUsingStaticRendering())return e.call(this);l(this,g,!1),l(this,w,!1);var a=x(this),i=e.bind(this),s=!1,c=new r.Reaction(a+".render()",(function(){if(!s&&(s=!0,!0!==n[O])){var e=!0;try{l(n,w,!0),n[g]||t.Component.prototype.forceUpdate.call(n),e=!1}finally{l(n,w,!1),e&&c.dispose()}}}));function u(){s=!1;var e=void 0,t=void 0;if(c.track((function(){try{t=r._allowStateChanges(!1,i)}catch(r){e=r}})),e)throw e;return t}return c.reactComponent=this,u[v]=c,this.render=u,u.call(this)}function R(e,r){return o.isUsingStaticRendering()&&console.warn("[mobx-react] It seems that a re-rendering of a React component is triggered while in static (server-side) mode. Please make sure components are rendered only once server-side."),this.state!==r||!c(this.props,e)}function S(e,t){var n=s("reactProp_"+t+"_valueHolder"),o=s("reactProp_"+t+"_atomHolder");function a(){return this[o]||l(this,o,r.createAtom("reactive "+t)),this[o]}Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){var e=!1;return r._allowStateReadsStart&&r._allowStateReadsEnd&&(e=r._allowStateReadsStart(!0)),a.call(this).reportObserved(),r._allowStateReadsStart&&r._allowStateReadsEnd&&r._allowStateReadsEnd(e),this[n]},set:function(e){this[w]||c(this[n],e)?l(this,n,e):(l(this,n,e),l(this,g,!0),a.call(this).reportChanged(),l(this,g,!1))}})}var C="function"==typeof Symbol&&Symbol.for,E=C?Symbol.for("react.forward_ref"):"function"==typeof t.forwardRef&&t.forwardRef((function(e){return null})).$$typeof,A=C?Symbol.for("react.memo"):"function"==typeof t.memo&&t.memo((function(e){return null})).$$typeof;function k(e){if(!0===e.isMobxInjector&&console.warn("Mobx observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'"),A&&e.$$typeof===A)throw new Error("Mobx observer: You are trying to use 'observer' on a function component wrapped in either another observer or 'React.memo'. The observer already applies 'React.memo' for you.");if(E&&e.$$typeof===E){var r=e.render;if("function"!=typeof r)throw new Error("render property of ForwardRef was not a function");return t.forwardRef((function(){var e=arguments;return t.createElement(o.Observer,null,(function(){return r.apply(void 0,e)}))}))}return"function"!=typeof e||e.prototype&&e.prototype.render||e.isReactClass||Object.prototype.isPrototypeOf.call(t.Component,e)?j(e):o.observer(e)}function U(){return(U=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var _=n.createContext({});function M(e){var r=e.children,t=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r.indexOf(t=a[n])>=0||(o[t]=e[t]);return o}(e,["children"]),o=n.useContext(_),a=n.useRef(U({},o,t));return n.createElement(_.Provider,{value:a.current},r)}function T(e,r,t,o){var a,i,s,c=n.forwardRef((function(t,o){var a=U({},t),i=n.useContext(_);return Object.assign(a,e(i||{},a)||{}),o&&(a.ref=o),n.createElement(r,a)}));return o&&(c=k(c)),c.isMobxInjector=!0,a=r,i=c,s=Object.getOwnPropertyNames(Object.getPrototypeOf(a)),Object.getOwnPropertyNames(a).forEach((function(e){f[e]||-1!==s.indexOf(e)||Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))})),c.wrappedComponent=r,c.displayName=function(e,r){var t=e.displayName||e.name||e.constructor&&e.constructor.name||"Component";return r?"inject-with-"+r+"("+t+")":"inject("+t+")"}(r,t),c}function $(e){return function(r,t){return e.forEach((function(e){if(!(e in t)){if(!(e in r))throw new Error("MobX injector: Store '"+e+"' is not available! Make sure it is provided by some Provider");t[e]=r[e]}})),t}}M.displayName="MobXProvider";var q=s("disposeOnUnmountProto"),N=s("disposeOnUnmountInst");function D(){var e=this;[].concat(this[q]||[],this[N]||[]).forEach((function(r){var t="string"==typeof r?e[r]:r;null!=t&&(Array.isArray(t)?t.map((function(e){return e()})):t())}))}function I(e){function t(t,n,o,a,i,s){for(var c=arguments.length,u=new Array(c>6?c-6:0),f=6;f<c;f++)u[f-6]=arguments[f];return r.untracked((function(){return a=a||"<<anonymous>>",s=s||o,null==n[o]?t?new Error("The "+i+" `"+s+"` is marked as required in `"+a+"`, but its value is `"+(null===n[o]?"null":"undefined")+"`."):null:e.apply(void 0,[n,o,a,i,s].concat(u))}))}var n=t.bind(null,!1);return n.isRequired=t.bind(null,!0),n}function L(e){var r=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,r){return"symbol"===e||"Symbol"===r["@@toStringTag"]||"function"==typeof Symbol&&r instanceof Symbol}(r,e)?"symbol":r}function X(e,t){return I((function(n,o,a,i,s){return r.untracked((function(){if(e&&L(n[o])===t.toLowerCase())return null;var i;switch(t){case"Array":i=r.isObservableArray;break;case"Object":i=r.isObservableObject;break;case"Map":i=r.isObservableMap;break;default:throw new Error("Unexpected mobxType: "+t)}var c=n[o];if(!i(c)){var u=function(e){var r=L(e);if("object"===r){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return r}(c),f=e?" or javascript `"+t.toLowerCase()+"`":"";return new Error("Invalid prop `"+s+"` of type `"+u+"` supplied to `"+a+"`, expected `mobx.Observable"+t+"`"+f+".")}return null}))}))}function F(e,t){return I((function(n,o,a,i,s){for(var c=arguments.length,u=new Array(c>5?c-5:0),f=5;f<c;f++)u[f-5]=arguments[f];return r.untracked((function(){if("function"!=typeof t)return new Error("Property `"+s+"` of component `"+a+"` has invalid PropType notation.");var r=X(e,"Array")(n,o,a,i,s);if(r instanceof Error)return r;for(var c=n[o],f=0;f<c.length;f++)if((r=t.apply(void 0,[c,f,a,i,s+"["+f+"]"].concat(u)))instanceof Error)return r;return null}))}))}var W={observableArray:X(!1,"Array"),observableArrayOf:F.bind(null,!1),observableMap:X(!1,"Map"),observableObject:X(!1,"Object"),arrayOrObservableArray:X(!0,"Array"),arrayOrObservableArrayOf:F.bind(null,!0),objectOrObservableObject:X(!0,"Object")};if(!t.Component)throw new Error("mobx-react requires React to be available");if(!r.observable)throw new Error("mobx-react requires mobx to be available");Object.defineProperty(exports,"Observer",{enumerable:!0,get:function(){return o.Observer}}),Object.defineProperty(exports,"enableStaticRendering",{enumerable:!0,get:function(){return o.enableStaticRendering}}),Object.defineProperty(exports,"isUsingStaticRendering",{enumerable:!0,get:function(){return o.isUsingStaticRendering}}),Object.defineProperty(exports,"observerBatching",{enumerable:!0,get:function(){return o.observerBatching}}),Object.defineProperty(exports,"useAsObservableSource",{enumerable:!0,get:function(){return o.useAsObservableSource}}),Object.defineProperty(exports,"useLocalObservable",{enumerable:!0,get:function(){return o.useLocalObservable}}),Object.defineProperty(exports,"useLocalStore",{enumerable:!0,get:function(){return o.useLocalStore}}),Object.defineProperty(exports,"useObserver",{enumerable:!0,get:function(){return o.useObserver}}),Object.defineProperty(exports,"useStaticRendering",{enumerable:!0,get:function(){return o.useStaticRendering}}),exports.MobXProviderContext=_,exports.PropTypes=W,exports.Provider=M,exports.disposeOnUnmount=function e(r,t){if(Array.isArray(t))return t.map((function(t){return e(r,t)}));var o=Object.getPrototypeOf(r).constructor,a=Object.getPrototypeOf(r.constructor),i=Object.getPrototypeOf(Object.getPrototypeOf(r));if(o!==n.Component&&o!==n.PureComponent&&a!==n.Component&&a!==n.PureComponent&&i!==n.Component&&i!==n.PureComponent)throw new Error("[mobx-react] disposeOnUnmount only supports direct subclasses of React.Component or React.PureComponent.");if("string"!=typeof t&&"function"!=typeof t&&!Array.isArray(t))throw new Error("[mobx-react] disposeOnUnmount only works if the parameter is either a property key or a function.");var s=!!r[q]||!!r[N];return("string"==typeof t?r[q]||(r[q]=[]):r[N]||(r[N]=[])).push(t),s||m(r,"componentWillUnmount",D),"string"!=typeof t?t:void 0},exports.inject=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];if("function"==typeof arguments[0]){var n=arguments[0];return function(e){return T(n,e,n.name,!0)}}return function(e){return T($(r),e,r.join("-"),!1)}},exports.observer=k; | ||
//# sourceMappingURL=mobxreact.cjs.production.min.js.map |
@@ -226,2 +226,8 @@ import { Reaction, _allowStateChanges, _allowStateReadsStart, _allowStateReadsEnd, $mobx, createAtom, untracked, isObservableMap, isObservableObject, isObservableArray, observable } from 'mobx'; | ||
if (typeof baseRender !== 'function') { | ||
var _displayName = getDisplayName(target); | ||
throw new Error("[mobx-react] class component (" + _displayName + ") is missing `render` method." + "\n`observer` requires `render` being a function defined on prototype." + "\n`render = () => {}` or `render = function() {}` is not supported."); | ||
} | ||
target.render = function () { | ||
@@ -240,5 +246,5 @@ return makeComponentReactive.call(this, baseRender); | ||
// Render may have been hot-swapped and/or overriden by a subclass. | ||
var _displayName = getDisplayName(this); | ||
var _displayName2 = getDisplayName(this); | ||
console.warn("The reactive render of an observer class component (" + _displayName + ") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed."); | ||
console.warn("The reactive render of an observer class component (" + _displayName2 + ") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed."); | ||
} | ||
@@ -245,0 +251,0 @@ }); |
@@ -226,2 +226,8 @@ import { Reaction, _allowStateChanges, _allowStateReadsStart, _allowStateReadsEnd, $mobx, createAtom, untracked, isObservableMap, isObservableObject, isObservableArray, observable } from 'mobx'; | ||
if (typeof baseRender !== 'function') { | ||
var _displayName = getDisplayName(target); | ||
throw new Error("[mobx-react] class component (" + _displayName + ") is missing `render` method." + "\n`observer` requires `render` being a function defined on prototype." + "\n`render = () => {}` or `render = function() {}` is not supported."); | ||
} | ||
target.render = function () { | ||
@@ -240,5 +246,5 @@ return makeComponentReactive.call(this, baseRender); | ||
// Render may have been hot-swapped and/or overriden by a subclass. | ||
var _displayName = getDisplayName(this); | ||
var _displayName2 = getDisplayName(this); | ||
console.warn("The reactive render of an observer class component (" + _displayName + ") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed."); | ||
console.warn("The reactive render of an observer class component (" + _displayName2 + ") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed."); | ||
} | ||
@@ -245,0 +251,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import{Reaction as e,_allowStateChanges as r,_allowStateReadsStart as t,_allowStateReadsEnd as n,$mobx as o,createAtom as a,untracked as i,isObservableMap as c,isObservableObject as s,isObservableArray as u,observable as f}from"mobx";import l,{PureComponent as p,Component as y,forwardRef as b,memo as d,createElement as v}from"react";import{isUsingStaticRendering as m,Observer as h,observer as O}from"mobx-react-lite";export{Observer,enableStaticRendering,isUsingStaticRendering,observerBatching,useAsObservableSource,useLocalObservable,useLocalStore,useObserver,useStaticRendering}from"mobx-react-lite";var w=0,g={};function j(e){return g[e]||(g[e]=function(e){if("function"==typeof Symbol)return Symbol(e);var r="__$mobx-react "+e+" ("+w+")";return w++,r}(e)),g[e]}function x(e,r){if(P(e,r))return!0;if("object"!=typeof e||null===e||"object"!=typeof r||null===r)return!1;var t=Object.keys(e),n=Object.keys(r);if(t.length!==n.length)return!1;for(var o=0;o<t.length;o++)if(!Object.hasOwnProperty.call(r,t[o])||!P(e[t[o]],r[t[o]]))return!1;return!0}function P(e,r){return e===r?0!==e||1/e==1/r:e!=e&&r!=r}var E={$$typeof:1,render:1,compare:1,type:1,childContextTypes:1,contextType:1,contextTypes:1,defaultProps:1,getDefaultProps:1,getDerivedStateFromError:1,getDerivedStateFromProps:1,mixins:1,displayName:1,propTypes:1};function C(e,r,t){Object.hasOwnProperty.call(e,r)?e[r]=t:Object.defineProperty(e,r,{enumerable:!1,configurable:!0,writable:!0,value:t})}var A=j("patchMixins"),R=j("patchedDefinition");function k(e,r){for(var t=this,n=arguments.length,o=new Array(n>2?n-2:0),a=2;a<n;a++)o[a-2]=arguments[a];r.locks++;try{var i;return null!=e&&(i=e.apply(this,o)),i}finally{r.locks--,0===r.locks&&r.methods.forEach((function(e){e.apply(t,o)}))}}function S(e,r){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];k.call.apply(k,[this,e,r].concat(n))}}function U(e,r,t){var n=function(e,r){var t=e[A]=e[A]||{},n=t[r]=t[r]||{};return n.locks=n.locks||0,n.methods=n.methods||[],n}(e,r);n.methods.indexOf(t)<0&&n.methods.push(t);var o=Object.getOwnPropertyDescriptor(e,r);if(!o||!o[R]){var a=function e(r,t,n,o,a){var i,c=S(a,o);return(i={})[R]=!0,i.get=function(){return c},i.set=function(a){if(this===r)c=S(a,o);else{var i=e(this,t,n,o,a);Object.defineProperty(this,t,i)}},i.configurable=!0,i.enumerable=n,i}(e,r,o?o.enumerable:void 0,n,e[r]);Object.defineProperty(e,r,a)}}var M=o||"$mobx",T=j("isMobXReactObserver"),$=j("isUnmounted"),_=j("skipRender"),N=j("isForcingUpdate");function D(e){var r=e.prototype;if(e[T]){var t=I(r);console.warn("The provided component class ("+t+") \n has already been declared as an observer component.")}else e[T]=!0;if(r.componentWillReact)throw new Error("The componentWillReact life-cycle event is no longer supported");if(e.__proto__!==p)if(r.shouldComponentUpdate){if(r.shouldComponentUpdate!==F)throw new Error("It is not allowed to use shouldComponentUpdate in observer based components.")}else r.shouldComponentUpdate=F;L(r,"props"),L(r,"state");var n=r.render;return r.render=function(){return q.call(this,n)},U(r,"componentWillUnmount",(function(){var e;if(!0!==m()&&(null==(e=this.render[M])||e.dispose(),this[$]=!0,!this.render[M])){var r=I(this);console.warn("The reactive render of an observer class component ("+r+") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed.")}})),e}function I(e){return e.displayName||e.name||e.constructor&&(e.constructor.displayName||e.constructor.name)||"<component>"}function q(t){var n=this;if(!0===m())return t.call(this);C(this,_,!1),C(this,N,!1);var o=I(this),a=t.bind(this),i=!1,c=new e(o+".render()",(function(){if(!i&&(i=!0,!0!==n[$])){var e=!0;try{C(n,N,!0),n[_]||y.prototype.forceUpdate.call(n),e=!1}finally{C(n,N,!1),e&&c.dispose()}}}));function s(){i=!1;var e=void 0,t=void 0;if(c.track((function(){try{t=r(!1,a)}catch(r){e=r}})),e)throw e;return t}return c.reactComponent=this,s[M]=c,this.render=s,s.call(this)}function F(e,r){return m()&&console.warn("[mobx-react] It seems that a re-rendering of a React component is triggered while in static (server-side) mode. Please make sure components are rendered only once server-side."),this.state!==r||!x(this.props,e)}function L(e,r){var o=j("reactProp_"+r+"_valueHolder"),i=j("reactProp_"+r+"_atomHolder");function c(){return this[i]||C(this,i,a("reactive "+r)),this[i]}Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get:function(){var e=!1;return t&&n&&(e=t(!0)),c.call(this).reportObserved(),t&&n&&n(e),this[o]},set:function(e){this[N]||x(this[o],e)?C(this,o,e):(C(this,o,e),C(this,_,!0),c.call(this).reportChanged(),C(this,_,!1))}})}var W="function"==typeof Symbol&&Symbol.for,X=W?Symbol.for("react.forward_ref"):"function"==typeof b&&b((function(e){return null})).$$typeof,H=W?Symbol.for("react.memo"):"function"==typeof d&&d((function(e){return null})).$$typeof;function Y(e){if(!0===e.isMobxInjector&&console.warn("Mobx observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'"),H&&e.$$typeof===H)throw new Error("Mobx observer: You are trying to use 'observer' on a function component wrapped in either another observer or 'React.memo'. The observer already applies 'React.memo' for you.");if(X&&e.$$typeof===X){var r=e.render;if("function"!=typeof r)throw new Error("render property of ForwardRef was not a function");return b((function(){var e=arguments;return v(h,null,(function(){return r.apply(void 0,e)}))}))}return"function"!=typeof e||e.prototype&&e.prototype.render||e.isReactClass||Object.prototype.isPrototypeOf.call(y,e)?D(e):O(e)}function B(){return(B=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var z=l.createContext({});function G(e){var r=e.children,t=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r.indexOf(t=a[n])>=0||(o[t]=e[t]);return o}(e,["children"]),n=l.useContext(z),o=l.useRef(B({},n,t));return l.createElement(z.Provider,{value:o.current},r)}function J(e,r,t,n){var o,a,i,c=l.forwardRef((function(t,n){var o=B({},t),a=l.useContext(z);return Object.assign(o,e(a||{},o)||{}),n&&(o.ref=n),l.createElement(r,o)}));return n&&(c=Y(c)),c.isMobxInjector=!0,o=r,a=c,i=Object.getOwnPropertyNames(Object.getPrototypeOf(o)),Object.getOwnPropertyNames(o).forEach((function(e){E[e]||-1!==i.indexOf(e)||Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(o,e))})),c.wrappedComponent=r,c.displayName=function(e,r){var t=e.displayName||e.name||e.constructor&&e.constructor.name||"Component";return r?"inject-with-"+r+"("+t+")":"inject("+t+")"}(r,t),c}function K(e){return function(r,t){return e.forEach((function(e){if(!(e in t)){if(!(e in r))throw new Error("MobX injector: Store '"+e+"' is not available! Make sure it is provided by some Provider");t[e]=r[e]}})),t}}function Q(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];if("function"==typeof arguments[0]){var n=arguments[0];return function(e){return J(n,e,n.name,!0)}}return function(e){return J(K(r),e,r.join("-"),!1)}}G.displayName="MobXProvider";var V=j("disposeOnUnmountProto"),Z=j("disposeOnUnmountInst");function ee(){var e=this;[].concat(this[V]||[],this[Z]||[]).forEach((function(r){var t="string"==typeof r?e[r]:r;null!=t&&(Array.isArray(t)?t.map((function(e){return e()})):t())}))}function re(e,r){if(Array.isArray(r))return r.map((function(r){return re(e,r)}));var t=Object.getPrototypeOf(e).constructor,n=Object.getPrototypeOf(e.constructor),o=Object.getPrototypeOf(Object.getPrototypeOf(e));if(t!==l.Component&&t!==l.PureComponent&&n!==l.Component&&n!==l.PureComponent&&o!==l.Component&&o!==l.PureComponent)throw new Error("[mobx-react] disposeOnUnmount only supports direct subclasses of React.Component or React.PureComponent.");if("string"!=typeof r&&"function"!=typeof r&&!Array.isArray(r))throw new Error("[mobx-react] disposeOnUnmount only works if the parameter is either a property key or a function.");var a=!!e[V]||!!e[Z];return("string"==typeof r?e[V]||(e[V]=[]):e[Z]||(e[Z]=[])).push(r),a||U(e,"componentWillUnmount",ee),"string"!=typeof r?r:void 0}function te(e){function r(r,t,n,o,a,c){for(var s=arguments.length,u=new Array(s>6?s-6:0),f=6;f<s;f++)u[f-6]=arguments[f];return i((function(){return o=o||"<<anonymous>>",c=c||n,null==t[n]?r?new Error("The "+a+" `"+c+"` is marked as required in `"+o+"`, but its value is `"+(null===t[n]?"null":"undefined")+"`."):null:e.apply(void 0,[t,n,o,a,c].concat(u))}))}var t=r.bind(null,!1);return t.isRequired=r.bind(null,!0),t}function ne(e){var r=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,r){return"symbol"===e||"Symbol"===r["@@toStringTag"]||"function"==typeof Symbol&&r instanceof Symbol}(r,e)?"symbol":r}function oe(e,r){return te((function(t,n,o,a,f){return i((function(){if(e&&ne(t[n])===r.toLowerCase())return null;var a;switch(r){case"Array":a=u;break;case"Object":a=s;break;case"Map":a=c;break;default:throw new Error("Unexpected mobxType: "+r)}var i=t[n];if(!a(i)){var l=function(e){var r=ne(e);if("object"===r){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return r}(i),p=e?" or javascript `"+r.toLowerCase()+"`":"";return new Error("Invalid prop `"+f+"` of type `"+l+"` supplied to `"+o+"`, expected `mobx.Observable"+r+"`"+p+".")}return null}))}))}function ae(e,r){return te((function(t,n,o,a,c){for(var s=arguments.length,u=new Array(s>5?s-5:0),f=5;f<s;f++)u[f-5]=arguments[f];return i((function(){if("function"!=typeof r)return new Error("Property `"+c+"` of component `"+o+"` has invalid PropType notation.");var i=oe(e,"Array")(t,n,o,a,c);if(i instanceof Error)return i;for(var s=t[n],f=0;f<s.length;f++)if((i=r.apply(void 0,[s,f,o,a,c+"["+f+"]"].concat(u)))instanceof Error)return i;return null}))}))}var ie={observableArray:oe(!1,"Array"),observableArrayOf:ae.bind(null,!1),observableMap:oe(!1,"Map"),observableObject:oe(!1,"Object"),arrayOrObservableArray:oe(!0,"Array"),arrayOrObservableArrayOf:ae.bind(null,!0),objectOrObservableObject:oe(!0,"Object")};if(!y)throw new Error("mobx-react requires React to be available");if(!f)throw new Error("mobx-react requires mobx to be available");export{z as MobXProviderContext,ie as PropTypes,G as Provider,re as disposeOnUnmount,Q as inject,Y as observer}; | ||
import{Reaction as e,_allowStateChanges as r,_allowStateReadsStart as t,_allowStateReadsEnd as n,$mobx as o,createAtom as i,untracked as a,isObservableMap as c,isObservableObject as s,isObservableArray as u,observable as f}from"mobx";import l,{PureComponent as p,Component as y,forwardRef as b,memo as d,createElement as m}from"react";import{isUsingStaticRendering as v,Observer as h,observer as O}from"mobx-react-lite";export{Observer,enableStaticRendering,isUsingStaticRendering,observerBatching,useAsObservableSource,useLocalObservable,useLocalStore,useObserver,useStaticRendering}from"mobx-react-lite";var w=0,g={};function j(e){return g[e]||(g[e]=function(e){if("function"==typeof Symbol)return Symbol(e);var r="__$mobx-react "+e+" ("+w+")";return w++,r}(e)),g[e]}function x(e,r){if(P(e,r))return!0;if("object"!=typeof e||null===e||"object"!=typeof r||null===r)return!1;var t=Object.keys(e),n=Object.keys(r);if(t.length!==n.length)return!1;for(var o=0;o<t.length;o++)if(!Object.hasOwnProperty.call(r,t[o])||!P(e[t[o]],r[t[o]]))return!1;return!0}function P(e,r){return e===r?0!==e||1/e==1/r:e!=e&&r!=r}var E={$$typeof:1,render:1,compare:1,type:1,childContextTypes:1,contextType:1,contextTypes:1,defaultProps:1,getDefaultProps:1,getDerivedStateFromError:1,getDerivedStateFromProps:1,mixins:1,displayName:1,propTypes:1};function C(e,r,t){Object.hasOwnProperty.call(e,r)?e[r]=t:Object.defineProperty(e,r,{enumerable:!1,configurable:!0,writable:!0,value:t})}var A=j("patchMixins"),R=j("patchedDefinition");function k(e,r){for(var t=this,n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];r.locks++;try{var a;return null!=e&&(a=e.apply(this,o)),a}finally{r.locks--,0===r.locks&&r.methods.forEach((function(e){e.apply(t,o)}))}}function S(e,r){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];k.call.apply(k,[this,e,r].concat(n))}}function U(e,r,t){var n=function(e,r){var t=e[A]=e[A]||{},n=t[r]=t[r]||{};return n.locks=n.locks||0,n.methods=n.methods||[],n}(e,r);n.methods.indexOf(t)<0&&n.methods.push(t);var o=Object.getOwnPropertyDescriptor(e,r);if(!o||!o[R]){var i=function e(r,t,n,o,i){var a,c=S(i,o);return(a={})[R]=!0,a.get=function(){return c},a.set=function(i){if(this===r)c=S(i,o);else{var a=e(this,t,n,o,i);Object.defineProperty(this,t,a)}},a.configurable=!0,a.enumerable=n,a}(e,r,o?o.enumerable:void 0,n,e[r]);Object.defineProperty(e,r,i)}}var M=o||"$mobx",T=j("isMobXReactObserver"),$=j("isUnmounted"),_=j("skipRender"),N=j("isForcingUpdate");function D(e){var r=e.prototype;if(e[T]){var t=I(r);console.warn("The provided component class ("+t+") \n has already been declared as an observer component.")}else e[T]=!0;if(r.componentWillReact)throw new Error("The componentWillReact life-cycle event is no longer supported");if(e.__proto__!==p)if(r.shouldComponentUpdate){if(r.shouldComponentUpdate!==F)throw new Error("It is not allowed to use shouldComponentUpdate in observer based components.")}else r.shouldComponentUpdate=F;L(r,"props"),L(r,"state");var n=r.render;if("function"!=typeof n){var o=I(r);throw new Error("[mobx-react] class component ("+o+") is missing `render` method.\n`observer` requires `render` being a function defined on prototype.\n`render = () => {}` or `render = function() {}` is not supported.")}return r.render=function(){return q.call(this,n)},U(r,"componentWillUnmount",(function(){var e;if(!0!==v()&&(null==(e=this.render[M])||e.dispose(),this[$]=!0,!this.render[M])){var r=I(this);console.warn("The reactive render of an observer class component ("+r+") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed.")}})),e}function I(e){return e.displayName||e.name||e.constructor&&(e.constructor.displayName||e.constructor.name)||"<component>"}function q(t){var n=this;if(!0===v())return t.call(this);C(this,_,!1),C(this,N,!1);var o=I(this),i=t.bind(this),a=!1,c=new e(o+".render()",(function(){if(!a&&(a=!0,!0!==n[$])){var e=!0;try{C(n,N,!0),n[_]||y.prototype.forceUpdate.call(n),e=!1}finally{C(n,N,!1),e&&c.dispose()}}}));function s(){a=!1;var e=void 0,t=void 0;if(c.track((function(){try{t=r(!1,i)}catch(r){e=r}})),e)throw e;return t}return c.reactComponent=this,s[M]=c,this.render=s,s.call(this)}function F(e,r){return v()&&console.warn("[mobx-react] It seems that a re-rendering of a React component is triggered while in static (server-side) mode. Please make sure components are rendered only once server-side."),this.state!==r||!x(this.props,e)}function L(e,r){var o=j("reactProp_"+r+"_valueHolder"),a=j("reactProp_"+r+"_atomHolder");function c(){return this[a]||C(this,a,i("reactive "+r)),this[a]}Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get:function(){var e=!1;return t&&n&&(e=t(!0)),c.call(this).reportObserved(),t&&n&&n(e),this[o]},set:function(e){this[N]||x(this[o],e)?C(this,o,e):(C(this,o,e),C(this,_,!0),c.call(this).reportChanged(),C(this,_,!1))}})}var W="function"==typeof Symbol&&Symbol.for,X=W?Symbol.for("react.forward_ref"):"function"==typeof b&&b((function(e){return null})).$$typeof,H=W?Symbol.for("react.memo"):"function"==typeof d&&d((function(e){return null})).$$typeof;function Y(e){if(!0===e.isMobxInjector&&console.warn("Mobx observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'"),H&&e.$$typeof===H)throw new Error("Mobx observer: You are trying to use 'observer' on a function component wrapped in either another observer or 'React.memo'. The observer already applies 'React.memo' for you.");if(X&&e.$$typeof===X){var r=e.render;if("function"!=typeof r)throw new Error("render property of ForwardRef was not a function");return b((function(){var e=arguments;return m(h,null,(function(){return r.apply(void 0,e)}))}))}return"function"!=typeof e||e.prototype&&e.prototype.render||e.isReactClass||Object.prototype.isPrototypeOf.call(y,e)?D(e):O(e)}function B(){return(B=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var z=l.createContext({});function G(e){var r=e.children,t=function(e,r){if(null==e)return{};var t,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r.indexOf(t=i[n])>=0||(o[t]=e[t]);return o}(e,["children"]),n=l.useContext(z),o=l.useRef(B({},n,t));return l.createElement(z.Provider,{value:o.current},r)}function J(e,r,t,n){var o,i,a,c=l.forwardRef((function(t,n){var o=B({},t),i=l.useContext(z);return Object.assign(o,e(i||{},o)||{}),n&&(o.ref=n),l.createElement(r,o)}));return n&&(c=Y(c)),c.isMobxInjector=!0,o=r,i=c,a=Object.getOwnPropertyNames(Object.getPrototypeOf(o)),Object.getOwnPropertyNames(o).forEach((function(e){E[e]||-1!==a.indexOf(e)||Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(o,e))})),c.wrappedComponent=r,c.displayName=function(e,r){var t=e.displayName||e.name||e.constructor&&e.constructor.name||"Component";return r?"inject-with-"+r+"("+t+")":"inject("+t+")"}(r,t),c}function K(e){return function(r,t){return e.forEach((function(e){if(!(e in t)){if(!(e in r))throw new Error("MobX injector: Store '"+e+"' is not available! Make sure it is provided by some Provider");t[e]=r[e]}})),t}}function Q(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];if("function"==typeof arguments[0]){var n=arguments[0];return function(e){return J(n,e,n.name,!0)}}return function(e){return J(K(r),e,r.join("-"),!1)}}G.displayName="MobXProvider";var V=j("disposeOnUnmountProto"),Z=j("disposeOnUnmountInst");function ee(){var e=this;[].concat(this[V]||[],this[Z]||[]).forEach((function(r){var t="string"==typeof r?e[r]:r;null!=t&&(Array.isArray(t)?t.map((function(e){return e()})):t())}))}function re(e,r){if(Array.isArray(r))return r.map((function(r){return re(e,r)}));var t=Object.getPrototypeOf(e).constructor,n=Object.getPrototypeOf(e.constructor),o=Object.getPrototypeOf(Object.getPrototypeOf(e));if(t!==l.Component&&t!==l.PureComponent&&n!==l.Component&&n!==l.PureComponent&&o!==l.Component&&o!==l.PureComponent)throw new Error("[mobx-react] disposeOnUnmount only supports direct subclasses of React.Component or React.PureComponent.");if("string"!=typeof r&&"function"!=typeof r&&!Array.isArray(r))throw new Error("[mobx-react] disposeOnUnmount only works if the parameter is either a property key or a function.");var i=!!e[V]||!!e[Z];return("string"==typeof r?e[V]||(e[V]=[]):e[Z]||(e[Z]=[])).push(r),i||U(e,"componentWillUnmount",ee),"string"!=typeof r?r:void 0}function te(e){function r(r,t,n,o,i,c){for(var s=arguments.length,u=new Array(s>6?s-6:0),f=6;f<s;f++)u[f-6]=arguments[f];return a((function(){return o=o||"<<anonymous>>",c=c||n,null==t[n]?r?new Error("The "+i+" `"+c+"` is marked as required in `"+o+"`, but its value is `"+(null===t[n]?"null":"undefined")+"`."):null:e.apply(void 0,[t,n,o,i,c].concat(u))}))}var t=r.bind(null,!1);return t.isRequired=r.bind(null,!0),t}function ne(e){var r=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,r){return"symbol"===e||"Symbol"===r["@@toStringTag"]||"function"==typeof Symbol&&r instanceof Symbol}(r,e)?"symbol":r}function oe(e,r){return te((function(t,n,o,i,f){return a((function(){if(e&&ne(t[n])===r.toLowerCase())return null;var i;switch(r){case"Array":i=u;break;case"Object":i=s;break;case"Map":i=c;break;default:throw new Error("Unexpected mobxType: "+r)}var a=t[n];if(!i(a)){var l=function(e){var r=ne(e);if("object"===r){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return r}(a),p=e?" or javascript `"+r.toLowerCase()+"`":"";return new Error("Invalid prop `"+f+"` of type `"+l+"` supplied to `"+o+"`, expected `mobx.Observable"+r+"`"+p+".")}return null}))}))}function ie(e,r){return te((function(t,n,o,i,c){for(var s=arguments.length,u=new Array(s>5?s-5:0),f=5;f<s;f++)u[f-5]=arguments[f];return a((function(){if("function"!=typeof r)return new Error("Property `"+c+"` of component `"+o+"` has invalid PropType notation.");var a=oe(e,"Array")(t,n,o,i,c);if(a instanceof Error)return a;for(var s=t[n],f=0;f<s.length;f++)if((a=r.apply(void 0,[s,f,o,i,c+"["+f+"]"].concat(u)))instanceof Error)return a;return null}))}))}var ae={observableArray:oe(!1,"Array"),observableArrayOf:ie.bind(null,!1),observableMap:oe(!1,"Map"),observableObject:oe(!1,"Object"),arrayOrObservableArray:oe(!0,"Array"),arrayOrObservableArrayOf:ie.bind(null,!0),objectOrObservableObject:oe(!0,"Object")};if(!y)throw new Error("mobx-react requires React to be available");if(!f)throw new Error("mobx-react requires mobx to be available");export{z as MobXProviderContext,ae as PropTypes,G as Provider,re as disposeOnUnmount,Q as inject,Y as observer}; | ||
//# sourceMappingURL=mobxreact.esm.production.min.js.map |
@@ -229,2 +229,8 @@ (function (global, factory) { | ||
if (typeof baseRender !== 'function') { | ||
var _displayName = getDisplayName(target); | ||
throw new Error("[mobx-react] class component (" + _displayName + ") is missing `render` method." + "\n`observer` requires `render` being a function defined on prototype." + "\n`render = () => {}` or `render = function() {}` is not supported."); | ||
} | ||
target.render = function () { | ||
@@ -243,5 +249,5 @@ return makeComponentReactive.call(this, baseRender); | ||
// Render may have been hot-swapped and/or overriden by a subclass. | ||
var _displayName = getDisplayName(this); | ||
var _displayName2 = getDisplayName(this); | ||
console.warn("The reactive render of an observer class component (" + _displayName + ") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed."); | ||
console.warn("The reactive render of an observer class component (" + _displayName2 + ") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed."); | ||
} | ||
@@ -248,0 +254,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("mobx"),require("react"),require("mobx-react-lite")):"function"==typeof define&&define.amd?define(["exports","mobx","react","mobx-react-lite"],r):r((e=e||self).mobxReact={},e.mobx,e.React,e.mobxReactLite)}(this,(function(e,r,t,n){"use strict";var o="default"in t?t.default:t,a=0,i={};function c(e){return i[e]||(i[e]=function(e){if("function"==typeof Symbol)return Symbol(e);var r="__$mobx-react "+e+" ("+a+")";return a++,r}(e)),i[e]}function s(e,r){if(u(e,r))return!0;if("object"!=typeof e||null===e||"object"!=typeof r||null===r)return!1;var t=Object.keys(e),n=Object.keys(r);if(t.length!==n.length)return!1;for(var o=0;o<t.length;o++)if(!Object.hasOwnProperty.call(r,t[o])||!u(e[t[o]],r[t[o]]))return!1;return!0}function u(e,r){return e===r?0!==e||1/e==1/r:e!=e&&r!=r}var f={$$typeof:1,render:1,compare:1,type:1,childContextTypes:1,contextType:1,contextTypes:1,defaultProps:1,getDefaultProps:1,getDerivedStateFromError:1,getDerivedStateFromProps:1,mixins:1,displayName:1,propTypes:1};function l(e,r,t){Object.hasOwnProperty.call(e,r)?e[r]=t:Object.defineProperty(e,r,{enumerable:!1,configurable:!0,writable:!0,value:t})}var p=c("patchMixins"),b=c("patchedDefinition");function d(e,r){for(var t=this,n=arguments.length,o=new Array(n>2?n-2:0),a=2;a<n;a++)o[a-2]=arguments[a];r.locks++;try{var i;return null!=e&&(i=e.apply(this,o)),i}finally{r.locks--,0===r.locks&&r.methods.forEach((function(e){e.apply(t,o)}))}}function y(e,r){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];d.call.apply(d,[this,e,r].concat(n))}}function m(e,r,t){var n=function(e,r){var t=e[p]=e[p]||{},n=t[r]=t[r]||{};return n.locks=n.locks||0,n.methods=n.methods||[],n}(e,r);n.methods.indexOf(t)<0&&n.methods.push(t);var o=Object.getOwnPropertyDescriptor(e,r);if(!o||!o[b]){var a=function e(r,t,n,o,a){var i,c=y(a,o);return(i={})[b]=!0,i.get=function(){return c},i.set=function(a){if(this===r)c=y(a,o);else{var i=e(this,t,n,o,a);Object.defineProperty(this,t,i)}},i.configurable=!0,i.enumerable=n,i}(e,r,o?o.enumerable:void 0,n,e[r]);Object.defineProperty(e,r,a)}}var v=r.$mobx||"$mobx",h=c("isMobXReactObserver"),O=c("isUnmounted"),g=c("skipRender"),w=c("isForcingUpdate");function j(e){var r=e.prototype;if(e[h]){var o=P(r);console.warn("The provided component class ("+o+") \n has already been declared as an observer component.")}else e[h]=!0;if(r.componentWillReact)throw new Error("The componentWillReact life-cycle event is no longer supported");if(e.__proto__!==t.PureComponent)if(r.shouldComponentUpdate){if(r.shouldComponentUpdate!==R)throw new Error("It is not allowed to use shouldComponentUpdate in observer based components.")}else r.shouldComponentUpdate=R;S(r,"props"),S(r,"state");var a=r.render;return r.render=function(){return x.call(this,a)},m(r,"componentWillUnmount",(function(){var e;if(!0!==n.isUsingStaticRendering()&&(null==(e=this.render[v])||e.dispose(),this[O]=!0,!this.render[v])){var r=P(this);console.warn("The reactive render of an observer class component ("+r+") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed.")}})),e}function P(e){return e.displayName||e.name||e.constructor&&(e.constructor.displayName||e.constructor.name)||"<component>"}function x(e){var o=this;if(!0===n.isUsingStaticRendering())return e.call(this);l(this,g,!1),l(this,w,!1);var a=P(this),i=e.bind(this),c=!1,s=new r.Reaction(a+".render()",(function(){if(!c&&(c=!0,!0!==o[O])){var e=!0;try{l(o,w,!0),o[g]||t.Component.prototype.forceUpdate.call(o),e=!1}finally{l(o,w,!1),e&&s.dispose()}}}));function u(){c=!1;var e=void 0,t=void 0;if(s.track((function(){try{t=r._allowStateChanges(!1,i)}catch(r){e=r}})),e)throw e;return t}return s.reactComponent=this,u[v]=s,this.render=u,u.call(this)}function R(e,r){return n.isUsingStaticRendering()&&console.warn("[mobx-react] It seems that a re-rendering of a React component is triggered while in static (server-side) mode. Please make sure components are rendered only once server-side."),this.state!==r||!s(this.props,e)}function S(e,t){var n=c("reactProp_"+t+"_valueHolder"),o=c("reactProp_"+t+"_atomHolder");function a(){return this[o]||l(this,o,r.createAtom("reactive "+t)),this[o]}Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){var e=!1;return r._allowStateReadsStart&&r._allowStateReadsEnd&&(e=r._allowStateReadsStart(!0)),a.call(this).reportObserved(),r._allowStateReadsStart&&r._allowStateReadsEnd&&r._allowStateReadsEnd(e),this[n]},set:function(e){this[w]||s(this[n],e)?l(this,n,e):(l(this,n,e),l(this,g,!0),a.call(this).reportChanged(),l(this,g,!1))}})}var C="function"==typeof Symbol&&Symbol.for,E=C?Symbol.for("react.forward_ref"):"function"==typeof t.forwardRef&&t.forwardRef((function(e){return null})).$$typeof,A=C?Symbol.for("react.memo"):"function"==typeof t.memo&&t.memo((function(e){return null})).$$typeof;function k(e){if(!0===e.isMobxInjector&&console.warn("Mobx observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'"),A&&e.$$typeof===A)throw new Error("Mobx observer: You are trying to use 'observer' on a function component wrapped in either another observer or 'React.memo'. The observer already applies 'React.memo' for you.");if(E&&e.$$typeof===E){var r=e.render;if("function"!=typeof r)throw new Error("render property of ForwardRef was not a function");return t.forwardRef((function(){var e=arguments;return t.createElement(n.Observer,null,(function(){return r.apply(void 0,e)}))}))}return"function"!=typeof e||e.prototype&&e.prototype.render||e.isReactClass||Object.prototype.isPrototypeOf.call(t.Component,e)?j(e):n.observer(e)}function U(){return(U=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var _=o.createContext({});function M(e){var r=e.children,t=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r.indexOf(t=a[n])>=0||(o[t]=e[t]);return o}(e,["children"]),n=o.useContext(_),a=o.useRef(U({},n,t));return o.createElement(_.Provider,{value:a.current},r)}function T(e,r,t,n){var a,i,c,s=o.forwardRef((function(t,n){var a=U({},t),i=o.useContext(_);return Object.assign(a,e(i||{},a)||{}),n&&(a.ref=n),o.createElement(r,a)}));return n&&(s=k(s)),s.isMobxInjector=!0,a=r,i=s,c=Object.getOwnPropertyNames(Object.getPrototypeOf(a)),Object.getOwnPropertyNames(a).forEach((function(e){f[e]||-1!==c.indexOf(e)||Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))})),s.wrappedComponent=r,s.displayName=function(e,r){var t=e.displayName||e.name||e.constructor&&e.constructor.name||"Component";return r?"inject-with-"+r+"("+t+")":"inject("+t+")"}(r,t),s}function $(e){return function(r,t){return e.forEach((function(e){if(!(e in t)){if(!(e in r))throw new Error("MobX injector: Store '"+e+"' is not available! Make sure it is provided by some Provider");t[e]=r[e]}})),t}}M.displayName="MobXProvider";var N=c("disposeOnUnmountProto"),q=c("disposeOnUnmountInst");function D(){var e=this;[].concat(this[N]||[],this[q]||[]).forEach((function(r){var t="string"==typeof r?e[r]:r;null!=t&&(Array.isArray(t)?t.map((function(e){return e()})):t())}))}function L(e){function t(t,n,o,a,i,c){for(var s=arguments.length,u=new Array(s>6?s-6:0),f=6;f<s;f++)u[f-6]=arguments[f];return r.untracked((function(){return a=a||"<<anonymous>>",c=c||o,null==n[o]?t?new Error("The "+i+" `"+c+"` is marked as required in `"+a+"`, but its value is `"+(null===n[o]?"null":"undefined")+"`."):null:e.apply(void 0,[n,o,a,i,c].concat(u))}))}var n=t.bind(null,!1);return n.isRequired=t.bind(null,!0),n}function I(e){var r=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,r){return"symbol"===e||"Symbol"===r["@@toStringTag"]||"function"==typeof Symbol&&r instanceof Symbol}(r,e)?"symbol":r}function X(e,t){return L((function(n,o,a,i,c){return r.untracked((function(){if(e&&I(n[o])===t.toLowerCase())return null;var i;switch(t){case"Array":i=r.isObservableArray;break;case"Object":i=r.isObservableObject;break;case"Map":i=r.isObservableMap;break;default:throw new Error("Unexpected mobxType: "+t)}var s=n[o];if(!i(s)){var u=function(e){var r=I(e);if("object"===r){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return r}(s),f=e?" or javascript `"+t.toLowerCase()+"`":"";return new Error("Invalid prop `"+c+"` of type `"+u+"` supplied to `"+a+"`, expected `mobx.Observable"+t+"`"+f+".")}return null}))}))}function F(e,t){return L((function(n,o,a,i,c){for(var s=arguments.length,u=new Array(s>5?s-5:0),f=5;f<s;f++)u[f-5]=arguments[f];return r.untracked((function(){if("function"!=typeof t)return new Error("Property `"+c+"` of component `"+a+"` has invalid PropType notation.");var r=X(e,"Array")(n,o,a,i,c);if(r instanceof Error)return r;for(var s=n[o],f=0;f<s.length;f++)if((r=t.apply(void 0,[s,f,a,i,c+"["+f+"]"].concat(u)))instanceof Error)return r;return null}))}))}var W={observableArray:X(!1,"Array"),observableArrayOf:F.bind(null,!1),observableMap:X(!1,"Map"),observableObject:X(!1,"Object"),arrayOrObservableArray:X(!0,"Array"),arrayOrObservableArrayOf:F.bind(null,!0),objectOrObservableObject:X(!0,"Object")};if(!t.Component)throw new Error("mobx-react requires React to be available");if(!r.observable)throw new Error("mobx-react requires mobx to be available");Object.defineProperty(e,"Observer",{enumerable:!0,get:function(){return n.Observer}}),Object.defineProperty(e,"enableStaticRendering",{enumerable:!0,get:function(){return n.enableStaticRendering}}),Object.defineProperty(e,"isUsingStaticRendering",{enumerable:!0,get:function(){return n.isUsingStaticRendering}}),Object.defineProperty(e,"observerBatching",{enumerable:!0,get:function(){return n.observerBatching}}),Object.defineProperty(e,"useAsObservableSource",{enumerable:!0,get:function(){return n.useAsObservableSource}}),Object.defineProperty(e,"useLocalObservable",{enumerable:!0,get:function(){return n.useLocalObservable}}),Object.defineProperty(e,"useLocalStore",{enumerable:!0,get:function(){return n.useLocalStore}}),Object.defineProperty(e,"useObserver",{enumerable:!0,get:function(){return n.useObserver}}),Object.defineProperty(e,"useStaticRendering",{enumerable:!0,get:function(){return n.useStaticRendering}}),e.MobXProviderContext=_,e.PropTypes=W,e.Provider=M,e.disposeOnUnmount=function e(r,t){if(Array.isArray(t))return t.map((function(t){return e(r,t)}));var n=Object.getPrototypeOf(r).constructor,a=Object.getPrototypeOf(r.constructor),i=Object.getPrototypeOf(Object.getPrototypeOf(r));if(n!==o.Component&&n!==o.PureComponent&&a!==o.Component&&a!==o.PureComponent&&i!==o.Component&&i!==o.PureComponent)throw new Error("[mobx-react] disposeOnUnmount only supports direct subclasses of React.Component or React.PureComponent.");if("string"!=typeof t&&"function"!=typeof t&&!Array.isArray(t))throw new Error("[mobx-react] disposeOnUnmount only works if the parameter is either a property key or a function.");var c=!!r[N]||!!r[q];return("string"==typeof t?r[N]||(r[N]=[]):r[q]||(r[q]=[])).push(t),c||m(r,"componentWillUnmount",D),"string"!=typeof t?t:void 0},e.inject=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];if("function"==typeof arguments[0]){var n=arguments[0];return function(e){return T(n,e,n.name,!0)}}return function(e){return T($(r),e,r.join("-"),!1)}},e.observer=k,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("mobx"),require("react"),require("mobx-react-lite")):"function"==typeof define&&define.amd?define(["exports","mobx","react","mobx-react-lite"],r):r((e=e||self).mobxReact={},e.mobx,e.React,e.mobxReactLite)}(this,(function(e,r,t,n){"use strict";var o="default"in t?t.default:t,a=0,i={};function c(e){return i[e]||(i[e]=function(e){if("function"==typeof Symbol)return Symbol(e);var r="__$mobx-react "+e+" ("+a+")";return a++,r}(e)),i[e]}function s(e,r){if(u(e,r))return!0;if("object"!=typeof e||null===e||"object"!=typeof r||null===r)return!1;var t=Object.keys(e),n=Object.keys(r);if(t.length!==n.length)return!1;for(var o=0;o<t.length;o++)if(!Object.hasOwnProperty.call(r,t[o])||!u(e[t[o]],r[t[o]]))return!1;return!0}function u(e,r){return e===r?0!==e||1/e==1/r:e!=e&&r!=r}var f={$$typeof:1,render:1,compare:1,type:1,childContextTypes:1,contextType:1,contextTypes:1,defaultProps:1,getDefaultProps:1,getDerivedStateFromError:1,getDerivedStateFromProps:1,mixins:1,displayName:1,propTypes:1};function l(e,r,t){Object.hasOwnProperty.call(e,r)?e[r]=t:Object.defineProperty(e,r,{enumerable:!1,configurable:!0,writable:!0,value:t})}var p=c("patchMixins"),b=c("patchedDefinition");function d(e,r){for(var t=this,n=arguments.length,o=new Array(n>2?n-2:0),a=2;a<n;a++)o[a-2]=arguments[a];r.locks++;try{var i;return null!=e&&(i=e.apply(this,o)),i}finally{r.locks--,0===r.locks&&r.methods.forEach((function(e){e.apply(t,o)}))}}function y(e,r){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];d.call.apply(d,[this,e,r].concat(n))}}function m(e,r,t){var n=function(e,r){var t=e[p]=e[p]||{},n=t[r]=t[r]||{};return n.locks=n.locks||0,n.methods=n.methods||[],n}(e,r);n.methods.indexOf(t)<0&&n.methods.push(t);var o=Object.getOwnPropertyDescriptor(e,r);if(!o||!o[b]){var a=function e(r,t,n,o,a){var i,c=y(a,o);return(i={})[b]=!0,i.get=function(){return c},i.set=function(a){if(this===r)c=y(a,o);else{var i=e(this,t,n,o,a);Object.defineProperty(this,t,i)}},i.configurable=!0,i.enumerable=n,i}(e,r,o?o.enumerable:void 0,n,e[r]);Object.defineProperty(e,r,a)}}var v=r.$mobx||"$mobx",h=c("isMobXReactObserver"),O=c("isUnmounted"),g=c("skipRender"),w=c("isForcingUpdate");function j(e){var r=e.prototype;if(e[h]){var o=P(r);console.warn("The provided component class ("+o+") \n has already been declared as an observer component.")}else e[h]=!0;if(r.componentWillReact)throw new Error("The componentWillReact life-cycle event is no longer supported");if(e.__proto__!==t.PureComponent)if(r.shouldComponentUpdate){if(r.shouldComponentUpdate!==R)throw new Error("It is not allowed to use shouldComponentUpdate in observer based components.")}else r.shouldComponentUpdate=R;S(r,"props"),S(r,"state");var a=r.render;if("function"!=typeof a){var i=P(r);throw new Error("[mobx-react] class component ("+i+") is missing `render` method.\n`observer` requires `render` being a function defined on prototype.\n`render = () => {}` or `render = function() {}` is not supported.")}return r.render=function(){return x.call(this,a)},m(r,"componentWillUnmount",(function(){var e;if(!0!==n.isUsingStaticRendering()&&(null==(e=this.render[v])||e.dispose(),this[O]=!0,!this.render[v])){var r=P(this);console.warn("The reactive render of an observer class component ("+r+") \n was overriden after MobX attached. This may result in a memory leak if the \n overriden reactive render was not properly disposed.")}})),e}function P(e){return e.displayName||e.name||e.constructor&&(e.constructor.displayName||e.constructor.name)||"<component>"}function x(e){var o=this;if(!0===n.isUsingStaticRendering())return e.call(this);l(this,g,!1),l(this,w,!1);var a=P(this),i=e.bind(this),c=!1,s=new r.Reaction(a+".render()",(function(){if(!c&&(c=!0,!0!==o[O])){var e=!0;try{l(o,w,!0),o[g]||t.Component.prototype.forceUpdate.call(o),e=!1}finally{l(o,w,!1),e&&s.dispose()}}}));function u(){c=!1;var e=void 0,t=void 0;if(s.track((function(){try{t=r._allowStateChanges(!1,i)}catch(r){e=r}})),e)throw e;return t}return s.reactComponent=this,u[v]=s,this.render=u,u.call(this)}function R(e,r){return n.isUsingStaticRendering()&&console.warn("[mobx-react] It seems that a re-rendering of a React component is triggered while in static (server-side) mode. Please make sure components are rendered only once server-side."),this.state!==r||!s(this.props,e)}function S(e,t){var n=c("reactProp_"+t+"_valueHolder"),o=c("reactProp_"+t+"_atomHolder");function a(){return this[o]||l(this,o,r.createAtom("reactive "+t)),this[o]}Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){var e=!1;return r._allowStateReadsStart&&r._allowStateReadsEnd&&(e=r._allowStateReadsStart(!0)),a.call(this).reportObserved(),r._allowStateReadsStart&&r._allowStateReadsEnd&&r._allowStateReadsEnd(e),this[n]},set:function(e){this[w]||s(this[n],e)?l(this,n,e):(l(this,n,e),l(this,g,!0),a.call(this).reportChanged(),l(this,g,!1))}})}var C="function"==typeof Symbol&&Symbol.for,E=C?Symbol.for("react.forward_ref"):"function"==typeof t.forwardRef&&t.forwardRef((function(e){return null})).$$typeof,A=C?Symbol.for("react.memo"):"function"==typeof t.memo&&t.memo((function(e){return null})).$$typeof;function k(e){if(!0===e.isMobxInjector&&console.warn("Mobx observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'"),A&&e.$$typeof===A)throw new Error("Mobx observer: You are trying to use 'observer' on a function component wrapped in either another observer or 'React.memo'. The observer already applies 'React.memo' for you.");if(E&&e.$$typeof===E){var r=e.render;if("function"!=typeof r)throw new Error("render property of ForwardRef was not a function");return t.forwardRef((function(){var e=arguments;return t.createElement(n.Observer,null,(function(){return r.apply(void 0,e)}))}))}return"function"!=typeof e||e.prototype&&e.prototype.render||e.isReactClass||Object.prototype.isPrototypeOf.call(t.Component,e)?j(e):n.observer(e)}function U(){return(U=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var _=o.createContext({});function M(e){var r=e.children,t=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r.indexOf(t=a[n])>=0||(o[t]=e[t]);return o}(e,["children"]),n=o.useContext(_),a=o.useRef(U({},n,t));return o.createElement(_.Provider,{value:a.current},r)}function T(e,r,t,n){var a,i,c,s=o.forwardRef((function(t,n){var a=U({},t),i=o.useContext(_);return Object.assign(a,e(i||{},a)||{}),n&&(a.ref=n),o.createElement(r,a)}));return n&&(s=k(s)),s.isMobxInjector=!0,a=r,i=s,c=Object.getOwnPropertyNames(Object.getPrototypeOf(a)),Object.getOwnPropertyNames(a).forEach((function(e){f[e]||-1!==c.indexOf(e)||Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))})),s.wrappedComponent=r,s.displayName=function(e,r){var t=e.displayName||e.name||e.constructor&&e.constructor.name||"Component";return r?"inject-with-"+r+"("+t+")":"inject("+t+")"}(r,t),s}function $(e){return function(r,t){return e.forEach((function(e){if(!(e in t)){if(!(e in r))throw new Error("MobX injector: Store '"+e+"' is not available! Make sure it is provided by some Provider");t[e]=r[e]}})),t}}M.displayName="MobXProvider";var q=c("disposeOnUnmountProto"),N=c("disposeOnUnmountInst");function D(){var e=this;[].concat(this[q]||[],this[N]||[]).forEach((function(r){var t="string"==typeof r?e[r]:r;null!=t&&(Array.isArray(t)?t.map((function(e){return e()})):t())}))}function L(e){function t(t,n,o,a,i,c){for(var s=arguments.length,u=new Array(s>6?s-6:0),f=6;f<s;f++)u[f-6]=arguments[f];return r.untracked((function(){return a=a||"<<anonymous>>",c=c||o,null==n[o]?t?new Error("The "+i+" `"+c+"` is marked as required in `"+a+"`, but its value is `"+(null===n[o]?"null":"undefined")+"`."):null:e.apply(void 0,[n,o,a,i,c].concat(u))}))}var n=t.bind(null,!1);return n.isRequired=t.bind(null,!0),n}function I(e){var r=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,r){return"symbol"===e||"Symbol"===r["@@toStringTag"]||"function"==typeof Symbol&&r instanceof Symbol}(r,e)?"symbol":r}function X(e,t){return L((function(n,o,a,i,c){return r.untracked((function(){if(e&&I(n[o])===t.toLowerCase())return null;var i;switch(t){case"Array":i=r.isObservableArray;break;case"Object":i=r.isObservableObject;break;case"Map":i=r.isObservableMap;break;default:throw new Error("Unexpected mobxType: "+t)}var s=n[o];if(!i(s)){var u=function(e){var r=I(e);if("object"===r){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return r}(s),f=e?" or javascript `"+t.toLowerCase()+"`":"";return new Error("Invalid prop `"+c+"` of type `"+u+"` supplied to `"+a+"`, expected `mobx.Observable"+t+"`"+f+".")}return null}))}))}function F(e,t){return L((function(n,o,a,i,c){for(var s=arguments.length,u=new Array(s>5?s-5:0),f=5;f<s;f++)u[f-5]=arguments[f];return r.untracked((function(){if("function"!=typeof t)return new Error("Property `"+c+"` of component `"+a+"` has invalid PropType notation.");var r=X(e,"Array")(n,o,a,i,c);if(r instanceof Error)return r;for(var s=n[o],f=0;f<s.length;f++)if((r=t.apply(void 0,[s,f,a,i,c+"["+f+"]"].concat(u)))instanceof Error)return r;return null}))}))}var W={observableArray:X(!1,"Array"),observableArrayOf:F.bind(null,!1),observableMap:X(!1,"Map"),observableObject:X(!1,"Object"),arrayOrObservableArray:X(!0,"Array"),arrayOrObservableArrayOf:F.bind(null,!0),objectOrObservableObject:X(!0,"Object")};if(!t.Component)throw new Error("mobx-react requires React to be available");if(!r.observable)throw new Error("mobx-react requires mobx to be available");Object.defineProperty(e,"Observer",{enumerable:!0,get:function(){return n.Observer}}),Object.defineProperty(e,"enableStaticRendering",{enumerable:!0,get:function(){return n.enableStaticRendering}}),Object.defineProperty(e,"isUsingStaticRendering",{enumerable:!0,get:function(){return n.isUsingStaticRendering}}),Object.defineProperty(e,"observerBatching",{enumerable:!0,get:function(){return n.observerBatching}}),Object.defineProperty(e,"useAsObservableSource",{enumerable:!0,get:function(){return n.useAsObservableSource}}),Object.defineProperty(e,"useLocalObservable",{enumerable:!0,get:function(){return n.useLocalObservable}}),Object.defineProperty(e,"useLocalStore",{enumerable:!0,get:function(){return n.useLocalStore}}),Object.defineProperty(e,"useObserver",{enumerable:!0,get:function(){return n.useObserver}}),Object.defineProperty(e,"useStaticRendering",{enumerable:!0,get:function(){return n.useStaticRendering}}),e.MobXProviderContext=_,e.PropTypes=W,e.Provider=M,e.disposeOnUnmount=function e(r,t){if(Array.isArray(t))return t.map((function(t){return e(r,t)}));var n=Object.getPrototypeOf(r).constructor,a=Object.getPrototypeOf(r.constructor),i=Object.getPrototypeOf(Object.getPrototypeOf(r));if(n!==o.Component&&n!==o.PureComponent&&a!==o.Component&&a!==o.PureComponent&&i!==o.Component&&i!==o.PureComponent)throw new Error("[mobx-react] disposeOnUnmount only supports direct subclasses of React.Component or React.PureComponent.");if("string"!=typeof t&&"function"!=typeof t&&!Array.isArray(t))throw new Error("[mobx-react] disposeOnUnmount only works if the parameter is either a property key or a function.");var c=!!r[q]||!!r[N];return("string"==typeof t?r[q]||(r[q]=[]):r[N]||(r[N]=[])).push(t),c||m(r,"componentWillUnmount",D),"string"!=typeof t?t:void 0},e.inject=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];if("function"==typeof arguments[0]){var n=arguments[0];return function(e){return T(n,e,n.name,!0)}}return function(e){return T($(r),e,r.join("-"),!1)}},e.observer=k,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=mobxreact.umd.production.min.js.map |
{ | ||
"name": "mobx-react", | ||
"version": "7.2.0", | ||
"version": "7.2.1", | ||
"description": "React bindings for MobX. Create fully reactive components.", | ||
@@ -37,3 +37,3 @@ "source": "src/index.ts", | ||
}, | ||
"homepage": "http://mobx.js.org/", | ||
"homepage": "https://mobx.js.org", | ||
"dependencies": { | ||
@@ -55,3 +55,3 @@ "mobx-react-lite": "^3.2.0" | ||
"devDependencies": { | ||
"mobx": "^6.3.1", | ||
"mobx": "^6.3.4", | ||
"mobx-react-lite": "^4.0.0" | ||
@@ -58,0 +58,0 @@ }, |
@@ -54,2 +54,10 @@ import { PureComponent, Component } from "react" | ||
const baseRender = target.render | ||
if (typeof baseRender !== 'function') { | ||
const displayName = getDisplayName(target) | ||
throw new Error( | ||
`[mobx-react] class component (${displayName}) is missing \`render\` method.` | ||
+ `\n\`observer\` requires \`render\` being a function defined on prototype.` | ||
+ `\n\`render = () => {}\` or \`render = function() {}\` is not supported.` | ||
) | ||
} | ||
target.render = function () { | ||
@@ -56,0 +64,0 @@ return makeComponentReactive.call(this, baseRender) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
616857
3679