Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mobx-react-lite

Package Overview
Dependencies
Maintainers
2
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-react-lite - npm Package Compare versions

Comparing version 3.2.1 to 3.2.2

6

CHANGELOG.md
# mobx-react-lite
## 3.2.2
### Patch Changes
- [`2dcfec09`](https://github.com/mobxjs/mobx/commit/2dcfec093533bd12bb564580b14ce6037ee1ebac) [#3172](https://github.com/mobxjs/mobx/pull/3172) Thanks [@urugator](https://github.com/urugator)! - support legacy context
## 3.2.1

@@ -4,0 +10,0 @@

16

dist/mobxreactlite.cjs.development.js

@@ -442,6 +442,11 @@ 'use strict';

wrappedComponent.displayName = baseComponentName; // memo; we are not interested in deep updates
wrappedComponent.displayName = baseComponentName; // Support legacy context: `contextTypes` must be applied before `memo`
if (baseComponent.contextTypes) {
wrappedComponent.contextTypes = baseComponent.contextTypes;
} // memo; we are not interested in deep updates
// in props; we assume that if deep objects are changed,
// this is in observables, which would have been tracked anyway
var memoComponent;

@@ -461,2 +466,11 @@

memoComponent.displayName = baseComponentName;
{
Object.defineProperty(memoComponent, 'contextTypes', {
set: function set() {
throw new Error("[mobx-react-lite] `" + (this.displayName || 'Component') + ".contextTypes` must be set before applying `observer`.");
}
});
}
return memoComponent;

@@ -463,0 +477,0 @@ } // based on https://github.com/mridgway/hoist-non-react-statics/blob/master/src/index.js

2

dist/mobxreactlite.cjs.production.min.js

@@ -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("react-dom");if(!t.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!r.makeObservable)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function u(e){e()}function i(e){e||(e=u),r.configure({reactionScheduler:e})}function a(e){return r.getDependencyTree(e)}var c="undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry;function s(e){return{reaction:e,mounted:!1,changedBeforeMount:!1,cleanAt:Date.now()+f}}var f=1e4;function l(e){var r=new Map,t=1,n=new e((function(e){var t=r.get(e);t&&(t.reaction.dispose(),r.delete(e))}));return{addReactionToTrack:function(e,o,u){var i=t++;return n.register(u,i,e),e.current=s(o),e.current.finalizationRegistryCleanupToken=i,r.set(i,e.current),e.current},recordReactionAsCommitted:function(e){n.unregister(e),e.current&&e.current.finalizationRegistryCleanupToken&&r.delete(e.current.finalizationRegistryCleanupToken)},forceCleanupTimerToRunNowForTests:function(){},resetCleanupScheduleForTests:function(){}}}function d(){return(d=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)}function v(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function p(){var e,r=new Set;function t(){void 0===e&&(e=setTimeout(n,1e4))}function n(){e=void 0;var n=Date.now();r.forEach((function(e){var t=e.current;t&&n>=t.cleanAt&&(t.reaction.dispose(),e.current=null,r.delete(e))})),r.size>0&&t()}return{addReactionToTrack:function(e,n,o){return e.current=s(n),r.add(e),t(),e.current},recordReactionAsCommitted:function(e){r.delete(e)},forceCleanupTimerToRunNowForTests:function(){e&&(clearTimeout(e),n())},resetCleanupScheduleForTests:function(){if(r.size>0){for(var t,n=function(e,r){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return v(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?v(e,void 0):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(r);!(t=n()).done;){var o=t.value,u=o.current;u&&(u.reaction.dispose(),o.current=null)}r.clear()}e&&(clearTimeout(e),e=void 0)}}}var b=c?l(c):p(),m=b.addReactionToTrack,y=b.recordReactionAsCommitted,g=b.resetCleanupScheduleForTests,h=!1;function w(e){h=e}function T(){return h}function R(e){return"observer"+e}var S=function(){};function x(){return new S}function O(e,t){if(void 0===t&&(t="observed"),T())return e();var o=n.useState(x)[0],u=n.useState()[1],i=function(){return u([])},c=n.useRef(null);if(!c.current)var s=new r.Reaction(R(t),(function(){f.mounted?i():f.changedBeforeMount=!0})),f=m(c,s,o);var l,d,v=c.current.reaction;if(n.useDebugValue(v,a),n.useEffect((function(){return y(c),c.current?(c.current.mounted=!0,c.current.changedBeforeMount&&(c.current.changedBeforeMount=!1,i())):(c.current={reaction:new r.Reaction(R(t),(function(){i()})),mounted:!0,changedBeforeMount:!1,cleanAt:Infinity},i()),function(){c.current.reaction.dispose(),c.current=null}}),[]),v.track((function(){try{l=e()}catch(e){d=e}})),d)throw d;return l}var A={$$typeof:!0,render:!0,compare:!0,type:!0};function C(e){var r=e.children||e.render;return"function"!=typeof r?null:O(r)}function j(e){var n=t.useState((function(){return r.observable(e,{},{deep:!1})}))[0];return r.runInAction((function(){Object.assign(n,e)})),n}C.displayName="Observer",i(o.unstable_batchedUpdates),exports.Observer=C,exports.clearTimers=g,exports.enableStaticRendering=w,exports.isObserverBatched=function(){return!0},exports.isUsingStaticRendering=T,exports.observer=function(e,r){if(T())return e;var n,o,u,i=d({forwardRef:!1},r),a=e.displayName||e.name,c=function(r,t){return O((function(){return e(r,t)}),a)};return c.displayName=a,n=t.memo(i.forwardRef?t.forwardRef(c):c),o=e,u=n,Object.keys(o).forEach((function(e){A[e]||Object.defineProperty(u,e,Object.getOwnPropertyDescriptor(o,e))})),n.displayName=a,n},exports.observerBatching=i,exports.useAsObservableSource=j,exports.useLocalObservable=function(e,n){return t.useState((function(){return r.observable(e(),n,{autoBind:!0})}))[0]},exports.useLocalStore=function(e,n){var o=n&&j(n);return t.useState((function(){return r.observable(e(o),void 0,{autoBind:!0})}))[0]},exports.useObserver=function(e,r){return void 0===r&&(r="observed"),O(e,r)},exports.useStaticRendering=function(e){w(e)};
"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("react-dom");if(!t.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!r.makeObservable)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function u(e){e()}function i(e){e||(e=u),r.configure({reactionScheduler:e})}function a(e){return r.getDependencyTree(e)}var c="undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry;function s(e){return{reaction:e,mounted:!1,changedBeforeMount:!1,cleanAt:Date.now()+f}}var f=1e4;function l(e){var r=new Map,t=1,n=new e((function(e){var t=r.get(e);t&&(t.reaction.dispose(),r.delete(e))}));return{addReactionToTrack:function(e,o,u){var i=t++;return n.register(u,i,e),e.current=s(o),e.current.finalizationRegistryCleanupToken=i,r.set(i,e.current),e.current},recordReactionAsCommitted:function(e){n.unregister(e),e.current&&e.current.finalizationRegistryCleanupToken&&r.delete(e.current.finalizationRegistryCleanupToken)},forceCleanupTimerToRunNowForTests:function(){},resetCleanupScheduleForTests:function(){}}}function d(){return(d=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)}function p(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function v(){var e,r=new Set;function t(){void 0===e&&(e=setTimeout(n,1e4))}function n(){e=void 0;var n=Date.now();r.forEach((function(e){var t=e.current;t&&n>=t.cleanAt&&(t.reaction.dispose(),e.current=null,r.delete(e))})),r.size>0&&t()}return{addReactionToTrack:function(e,n,o){return e.current=s(n),r.add(e),t(),e.current},recordReactionAsCommitted:function(e){r.delete(e)},forceCleanupTimerToRunNowForTests:function(){e&&(clearTimeout(e),n())},resetCleanupScheduleForTests:function(){if(r.size>0){for(var t,n=function(e,r){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return p(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?p(e,void 0):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(r);!(t=n()).done;){var o=t.value,u=o.current;u&&(u.reaction.dispose(),o.current=null)}r.clear()}e&&(clearTimeout(e),e=void 0)}}}var b=c?l(c):v(),m=b.addReactionToTrack,y=b.recordReactionAsCommitted,g=b.resetCleanupScheduleForTests,h=!1;function T(e){h=e}function w(){return h}function R(e){return"observer"+e}var S=function(){};function x(){return new S}function O(e,t){if(void 0===t&&(t="observed"),w())return e();var o=n.useState(x)[0],u=n.useState()[1],i=function(){return u([])},c=n.useRef(null);if(!c.current)var s=new r.Reaction(R(t),(function(){f.mounted?i():f.changedBeforeMount=!0})),f=m(c,s,o);var l,d,p=c.current.reaction;if(n.useDebugValue(p,a),n.useEffect((function(){return y(c),c.current?(c.current.mounted=!0,c.current.changedBeforeMount&&(c.current.changedBeforeMount=!1,i())):(c.current={reaction:new r.Reaction(R(t),(function(){i()})),mounted:!0,changedBeforeMount:!1,cleanAt:Infinity},i()),function(){c.current.reaction.dispose(),c.current=null}}),[]),p.track((function(){try{l=e()}catch(e){d=e}})),d)throw d;return l}var A={$$typeof:!0,render:!0,compare:!0,type:!0};function C(e){var r=e.children||e.render;return"function"!=typeof r?null:O(r)}function j(e){var n=t.useState((function(){return r.observable(e,{},{deep:!1})}))[0];return r.runInAction((function(){Object.assign(n,e)})),n}C.displayName="Observer",i(o.unstable_batchedUpdates),exports.Observer=C,exports.clearTimers=g,exports.enableStaticRendering=T,exports.isObserverBatched=function(){return!0},exports.isUsingStaticRendering=w,exports.observer=function(e,r){if(w())return e;var n,o,u,i=d({forwardRef:!1},r),a=e.displayName||e.name,c=function(r,t){return O((function(){return e(r,t)}),a)};return c.displayName=a,e.contextTypes&&(c.contextTypes=e.contextTypes),n=t.memo(i.forwardRef?t.forwardRef(c):c),o=e,u=n,Object.keys(o).forEach((function(e){A[e]||Object.defineProperty(u,e,Object.getOwnPropertyDescriptor(o,e))})),n.displayName=a,n},exports.observerBatching=i,exports.useAsObservableSource=j,exports.useLocalObservable=function(e,n){return t.useState((function(){return r.observable(e(),n,{autoBind:!0})}))[0]},exports.useLocalStore=function(e,n){var o=n&&j(n);return t.useState((function(){return r.observable(e(o),void 0,{autoBind:!0})}))[0]},exports.useObserver=function(e,r){return void 0===r&&(r="observed"),O(e,r)},exports.useStaticRendering=function(e){T(e)};
//# sourceMappingURL=mobxreactlite.cjs.production.min.js.map

@@ -435,6 +435,11 @@ import { makeObservable, configure, getDependencyTree, Reaction, observable, runInAction } from 'mobx';

wrappedComponent.displayName = baseComponentName; // memo; we are not interested in deep updates
wrappedComponent.displayName = baseComponentName; // Support legacy context: `contextTypes` must be applied before `memo`
if (baseComponent.contextTypes) {
wrappedComponent.contextTypes = baseComponent.contextTypes;
} // memo; we are not interested in deep updates
// in props; we assume that if deep objects are changed,
// this is in observables, which would have been tracked anyway
var memoComponent;

@@ -454,2 +459,11 @@

memoComponent.displayName = baseComponentName;
{
Object.defineProperty(memoComponent, 'contextTypes', {
set: function set() {
throw new Error("[mobx-react-lite] `" + (this.displayName || 'Component') + ".contextTypes` must be set before applying `observer`.");
}
});
}
return memoComponent;

@@ -456,0 +470,0 @@ } // based on https://github.com/mridgway/hoist-non-react-statics/blob/master/src/index.js

@@ -435,6 +435,11 @@ import { makeObservable, configure, getDependencyTree, Reaction, observable, runInAction } from 'mobx';

wrappedComponent.displayName = baseComponentName; // memo; we are not interested in deep updates
wrappedComponent.displayName = baseComponentName; // Support legacy context: `contextTypes` must be applied before `memo`
if (baseComponent.contextTypes) {
wrappedComponent.contextTypes = baseComponent.contextTypes;
} // memo; we are not interested in deep updates
// in props; we assume that if deep objects are changed,
// this is in observables, which would have been tracked anyway
var memoComponent;

@@ -454,2 +459,11 @@

memoComponent.displayName = baseComponentName;
if ("production" !== process.env.NODE_ENV) {
Object.defineProperty(memoComponent, 'contextTypes', {
set: function set() {
throw new Error("[mobx-react-lite] `" + (this.displayName || 'Component') + ".contextTypes` must be set before applying `observer`.");
}
});
}
return memoComponent;

@@ -456,0 +470,0 @@ } // based on https://github.com/mridgway/hoist-non-react-statics/blob/master/src/index.js

@@ -1,2 +0,2 @@

import{makeObservable as e,configure as r,getDependencyTree as n,Reaction as t,observable as o,runInAction as i}from"mobx";import u,{useState as a,memo as c,forwardRef as f}from"react";import{unstable_batchedUpdates as s}from"react-dom";if(!a)throw new Error("mobx-react-lite requires React with Hooks support");if(!e)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function d(e){e()}function l(e){e||(e=d),r({reactionScheduler:e})}var v=function(){return!0};function p(e){return n(e)}var m="undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry;function y(e){return{reaction:e,mounted:!1,changedBeforeMount:!1,cleanAt:Date.now()+b}}var b=1e4;function h(e){var r=new Map,n=1,t=new e((function(e){var n=r.get(e);n&&(n.reaction.dispose(),r.delete(e))}));return{addReactionToTrack:function(e,o,i){var u=n++;return t.register(i,u,e),e.current=y(o),e.current.finalizationRegistryCleanupToken=u,r.set(u,e.current),e.current},recordReactionAsCommitted:function(e){t.unregister(e),e.current&&e.current.finalizationRegistryCleanupToken&&r.delete(e.current.finalizationRegistryCleanupToken)},forceCleanupTimerToRunNowForTests:function(){},resetCleanupScheduleForTests:function(){}}}function g(){return(g=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}function w(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function T(){var e,r=new Set;function n(){void 0===e&&(e=setTimeout(t,1e4))}function t(){e=void 0;var t=Date.now();r.forEach((function(e){var n=e.current;n&&t>=n.cleanAt&&(n.reaction.dispose(),e.current=null,r.delete(e))})),r.size>0&&n()}return{addReactionToTrack:function(e,t,o){return e.current=y(t),r.add(e),n(),e.current},recordReactionAsCommitted:function(e){r.delete(e)},forceCleanupTimerToRunNowForTests:function(){e&&(clearTimeout(e),t())},resetCleanupScheduleForTests:function(){if(r.size>0){for(var n,t=function(e,r){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return w(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(r);!(n=t()).done;){var o=n.value,i=o.current;i&&(i.reaction.dispose(),o.current=null)}r.clear()}e&&(clearTimeout(e),e=void 0)}}}var R=m?h(m):T(),O=R.addReactionToTrack,S=R.recordReactionAsCommitted,A=R.resetCleanupScheduleForTests,C=!1;function j(e){C=e}function k(){return C}function z(e){return"observer"+e}var B=function(){};function F(){return new B}function M(e,r){if(void 0===r&&(r="observed"),k())return e();var n=u.useState(F)[0],o=u.useState()[1],i=function(){return o([])},a=u.useRef(null);if(!a.current)var c=new t(z(r),(function(){f.mounted?i():f.changedBeforeMount=!0})),f=O(a,c,n);var s,d,l=a.current.reaction;if(u.useDebugValue(l,p),u.useEffect((function(){return S(a),a.current?(a.current.mounted=!0,a.current.changedBeforeMount&&(a.current.changedBeforeMount=!1,i())):(a.current={reaction:new t(z(r),(function(){i()})),mounted:!0,changedBeforeMount:!1,cleanAt:Infinity},i()),function(){a.current.reaction.dispose(),a.current=null}}),[]),l.track((function(){try{s=e()}catch(e){d=e}})),d)throw d;return s}function x(e,r){if(k())return e;var n,t,o,i=g({forwardRef:!1},r),u=e.displayName||e.name,a=function(r,n){return M((function(){return e(r,n)}),u)};return a.displayName=u,n=c(i.forwardRef?f(a):a),t=e,o=n,Object.keys(t).forEach((function(e){E[e]||Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(t,e))})),n.displayName=u,n}var E={$$typeof:!0,render:!0,compare:!0,type:!0};function N(e){var r=e.children||e.render;return"function"!=typeof r?null:M(r)}function D(e,r){return a((function(){return o(e(),r,{autoBind:!0})}))[0]}function I(e){var r=a((function(){return o(e,{},{deep:!1})}))[0];return i((function(){Object.assign(r,e)})),r}function P(e,r){var n=r&&I(r);return a((function(){return o(e(n),void 0,{autoBind:!0})}))[0]}function $(e,r){return void 0===r&&(r="observed"),M(e,r)}function q(e){j(e)}N.displayName="Observer",l(s);export{N as Observer,A as clearTimers,j as enableStaticRendering,v as isObserverBatched,k as isUsingStaticRendering,x as observer,l as observerBatching,I as useAsObservableSource,D as useLocalObservable,P as useLocalStore,$ as useObserver,q as useStaticRendering};
import{makeObservable as e,configure as r,getDependencyTree as n,Reaction as t,observable as o,runInAction as i}from"mobx";import u,{useState as c,memo as a,forwardRef as f}from"react";import{unstable_batchedUpdates as s}from"react-dom";if(!c)throw new Error("mobx-react-lite requires React with Hooks support");if(!e)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function d(e){e()}function l(e){e||(e=d),r({reactionScheduler:e})}var v=function(){return!0};function p(e){return n(e)}var m="undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry;function y(e){return{reaction:e,mounted:!1,changedBeforeMount:!1,cleanAt:Date.now()+b}}var b=1e4;function h(e){var r=new Map,n=1,t=new e((function(e){var n=r.get(e);n&&(n.reaction.dispose(),r.delete(e))}));return{addReactionToTrack:function(e,o,i){var u=n++;return t.register(i,u,e),e.current=y(o),e.current.finalizationRegistryCleanupToken=u,r.set(u,e.current),e.current},recordReactionAsCommitted:function(e){t.unregister(e),e.current&&e.current.finalizationRegistryCleanupToken&&r.delete(e.current.finalizationRegistryCleanupToken)},forceCleanupTimerToRunNowForTests:function(){},resetCleanupScheduleForTests:function(){}}}function T(){return(T=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}function g(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function w(){var e,r=new Set;function n(){void 0===e&&(e=setTimeout(t,1e4))}function t(){e=void 0;var t=Date.now();r.forEach((function(e){var n=e.current;n&&t>=n.cleanAt&&(n.reaction.dispose(),e.current=null,r.delete(e))})),r.size>0&&n()}return{addReactionToTrack:function(e,t,o){return e.current=y(t),r.add(e),n(),e.current},recordReactionAsCommitted:function(e){r.delete(e)},forceCleanupTimerToRunNowForTests:function(){e&&(clearTimeout(e),t())},resetCleanupScheduleForTests:function(){if(r.size>0){for(var n,t=function(e,r){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return g(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(r);!(n=t()).done;){var o=n.value,i=o.current;i&&(i.reaction.dispose(),o.current=null)}r.clear()}e&&(clearTimeout(e),e=void 0)}}}var R=m?h(m):w(),O=R.addReactionToTrack,S=R.recordReactionAsCommitted,A=R.resetCleanupScheduleForTests,C=!1;function j(e){C=e}function k(){return C}function x(e){return"observer"+e}var z=function(){};function B(){return new z}function F(e,r){if(void 0===r&&(r="observed"),k())return e();var n=u.useState(B)[0],o=u.useState()[1],i=function(){return o([])},c=u.useRef(null);if(!c.current)var a=new t(x(r),(function(){f.mounted?i():f.changedBeforeMount=!0})),f=O(c,a,n);var s,d,l=c.current.reaction;if(u.useDebugValue(l,p),u.useEffect((function(){return S(c),c.current?(c.current.mounted=!0,c.current.changedBeforeMount&&(c.current.changedBeforeMount=!1,i())):(c.current={reaction:new t(x(r),(function(){i()})),mounted:!0,changedBeforeMount:!1,cleanAt:Infinity},i()),function(){c.current.reaction.dispose(),c.current=null}}),[]),l.track((function(){try{s=e()}catch(e){d=e}})),d)throw d;return s}function M(e,r){if(k())return e;var n,t,o,i=T({forwardRef:!1},r),u=e.displayName||e.name,c=function(r,n){return F((function(){return e(r,n)}),u)};return c.displayName=u,e.contextTypes&&(c.contextTypes=e.contextTypes),n=a(i.forwardRef?f(c):c),t=e,o=n,Object.keys(t).forEach((function(e){E[e]||Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(t,e))})),n.displayName=u,n}var E={$$typeof:!0,render:!0,compare:!0,type:!0};function N(e){var r=e.children||e.render;return"function"!=typeof r?null:F(r)}function D(e,r){return c((function(){return o(e(),r,{autoBind:!0})}))[0]}function I(e){var r=c((function(){return o(e,{},{deep:!1})}))[0];return i((function(){Object.assign(r,e)})),r}function P(e,r){var n=r&&I(r);return c((function(){return o(e(n),void 0,{autoBind:!0})}))[0]}function $(e,r){return void 0===r&&(r="observed"),F(e,r)}function q(e){j(e)}N.displayName="Observer",l(s);export{N as Observer,A as clearTimers,j as enableStaticRendering,v as isObserverBatched,k as isUsingStaticRendering,M as observer,l as observerBatching,I as useAsObservableSource,D as useLocalObservable,P as useLocalStore,$ as useObserver,q as useStaticRendering};
//# sourceMappingURL=mobxreactlite.esm.production.min.js.map

@@ -439,6 +439,11 @@ (function (global, factory) {

wrappedComponent.displayName = baseComponentName; // memo; we are not interested in deep updates
wrappedComponent.displayName = baseComponentName; // Support legacy context: `contextTypes` must be applied before `memo`
if (baseComponent.contextTypes) {
wrappedComponent.contextTypes = baseComponent.contextTypes;
} // memo; we are not interested in deep updates
// in props; we assume that if deep objects are changed,
// this is in observables, which would have been tracked anyway
var memoComponent;

@@ -458,2 +463,11 @@

memoComponent.displayName = baseComponentName;
{
Object.defineProperty(memoComponent, 'contextTypes', {
set: function set() {
throw new Error("[mobx-react-lite] `" + (this.displayName || 'Component') + ".contextTypes` must be set before applying `observer`.");
}
});
}
return memoComponent;

@@ -460,0 +474,0 @@ } // based on https://github.com/mridgway/hoist-non-react-statics/blob/master/src/index.js

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("mobx"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","mobx","react","react-dom"],r):r((e=e||self).mobxReactLite={},e.mobx,e.React,e.ReactDOM)}(this,(function(e,r,n,t){"use strict";var o="default"in n?n.default:n;if(!n.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!r.makeObservable)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function i(e){e()}function u(e){e||(e=i),r.configure({reactionScheduler:e})}function a(e){return r.getDependencyTree(e)}var c="undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry;function f(e){return{reaction:e,mounted:!1,changedBeforeMount:!1,cleanAt:Date.now()+s}}var s=1e4;function d(e){var r=new Map,n=1,t=new e((function(e){var n=r.get(e);n&&(n.reaction.dispose(),r.delete(e))}));return{addReactionToTrack:function(e,o,i){var u=n++;return t.register(i,u,e),e.current=f(o),e.current.finalizationRegistryCleanupToken=u,r.set(u,e.current),e.current},recordReactionAsCommitted:function(e){t.unregister(e),e.current&&e.current.finalizationRegistryCleanupToken&&r.delete(e.current.finalizationRegistryCleanupToken)},forceCleanupTimerToRunNowForTests:function(){},resetCleanupScheduleForTests:function(){}}}function l(){return(l=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}function v(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function b(){var e,r=new Set;function n(){void 0===e&&(e=setTimeout(t,1e4))}function t(){e=void 0;var t=Date.now();r.forEach((function(e){var n=e.current;n&&t>=n.cleanAt&&(n.reaction.dispose(),e.current=null,r.delete(e))})),r.size>0&&n()}return{addReactionToTrack:function(e,t,o){return e.current=f(t),r.add(e),n(),e.current},recordReactionAsCommitted:function(e){r.delete(e)},forceCleanupTimerToRunNowForTests:function(){e&&(clearTimeout(e),t())},resetCleanupScheduleForTests:function(){if(r.size>0){for(var n,t=function(e,r){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return v(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(r);!(n=t()).done;){var o=n.value,i=o.current;i&&(i.reaction.dispose(),o.current=null)}r.clear()}e&&(clearTimeout(e),e=void 0)}}}var p=c?d(c):b(),m=p.addReactionToTrack,y=p.recordReactionAsCommitted,g=p.resetCleanupScheduleForTests,h=!1;function R(e){h=e}function w(){return h}function T(e){return"observer"+e}var S=function(){};function O(){return new S}function A(e,n){if(void 0===n&&(n="observed"),w())return e();var t=o.useState(O)[0],i=o.useState()[1],u=function(){return i([])},c=o.useRef(null);if(!c.current)var f=new r.Reaction(T(n),(function(){s.mounted?u():s.changedBeforeMount=!0})),s=m(c,f,t);var d,l,v=c.current.reaction;if(o.useDebugValue(v,a),o.useEffect((function(){return y(c),c.current?(c.current.mounted=!0,c.current.changedBeforeMount&&(c.current.changedBeforeMount=!1,u())):(c.current={reaction:new r.Reaction(T(n),(function(){u()})),mounted:!0,changedBeforeMount:!1,cleanAt:Infinity},u()),function(){c.current.reaction.dispose(),c.current=null}}),[]),v.track((function(){try{d=e()}catch(e){l=e}})),l)throw l;return d}var C={$$typeof:!0,render:!0,compare:!0,type:!0};function j(e){var r=e.children||e.render;return"function"!=typeof r?null:A(r)}function x(e){var t=n.useState((function(){return r.observable(e,{},{deep:!1})}))[0];return r.runInAction((function(){Object.assign(t,e)})),t}j.displayName="Observer",u(t.unstable_batchedUpdates),e.Observer=j,e.clearTimers=g,e.enableStaticRendering=R,e.isObserverBatched=function(){return!0},e.isUsingStaticRendering=w,e.observer=function(e,r){if(w())return e;var t,o,i,u=l({forwardRef:!1},r),a=e.displayName||e.name,c=function(r,n){return A((function(){return e(r,n)}),a)};return c.displayName=a,t=n.memo(u.forwardRef?n.forwardRef(c):c),o=e,i=t,Object.keys(o).forEach((function(e){C[e]||Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(o,e))})),t.displayName=a,t},e.observerBatching=u,e.useAsObservableSource=x,e.useLocalObservable=function(e,t){return n.useState((function(){return r.observable(e(),t,{autoBind:!0})}))[0]},e.useLocalStore=function(e,t){var o=t&&x(t);return n.useState((function(){return r.observable(e(o),void 0,{autoBind:!0})}))[0]},e.useObserver=function(e,r){return void 0===r&&(r="observed"),A(e,r)},e.useStaticRendering=function(e){R(e)},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("mobx"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","mobx","react","react-dom"],r):r((e=e||self).mobxReactLite={},e.mobx,e.React,e.ReactDOM)}(this,(function(e,r,t,n){"use strict";var o="default"in t?t.default:t;if(!t.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!r.makeObservable)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function i(e){e()}function u(e){e||(e=i),r.configure({reactionScheduler:e})}function a(e){return r.getDependencyTree(e)}var c="undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry;function f(e){return{reaction:e,mounted:!1,changedBeforeMount:!1,cleanAt:Date.now()+s}}var s=1e4;function d(e){var r=new Map,t=1,n=new e((function(e){var t=r.get(e);t&&(t.reaction.dispose(),r.delete(e))}));return{addReactionToTrack:function(e,o,i){var u=t++;return n.register(i,u,e),e.current=f(o),e.current.finalizationRegistryCleanupToken=u,r.set(u,e.current),e.current},recordReactionAsCommitted:function(e){n.unregister(e),e.current&&e.current.finalizationRegistryCleanupToken&&r.delete(e.current.finalizationRegistryCleanupToken)},forceCleanupTimerToRunNowForTests:function(){},resetCleanupScheduleForTests:function(){}}}function l(){return(l=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)}function v(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function b(){var e,r=new Set;function t(){void 0===e&&(e=setTimeout(n,1e4))}function n(){e=void 0;var n=Date.now();r.forEach((function(e){var t=e.current;t&&n>=t.cleanAt&&(t.reaction.dispose(),e.current=null,r.delete(e))})),r.size>0&&t()}return{addReactionToTrack:function(e,n,o){return e.current=f(n),r.add(e),t(),e.current},recordReactionAsCommitted:function(e){r.delete(e)},forceCleanupTimerToRunNowForTests:function(){e&&(clearTimeout(e),n())},resetCleanupScheduleForTests:function(){if(r.size>0){for(var t,n=function(e,r){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return v(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?v(e,void 0):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(r);!(t=n()).done;){var o=t.value,i=o.current;i&&(i.reaction.dispose(),o.current=null)}r.clear()}e&&(clearTimeout(e),e=void 0)}}}var p=c?d(c):b(),m=p.addReactionToTrack,y=p.recordReactionAsCommitted,g=p.resetCleanupScheduleForTests,h=!1;function T(e){h=e}function R(){return h}function w(e){return"observer"+e}var S=function(){};function O(){return new S}function x(e,t){if(void 0===t&&(t="observed"),R())return e();var n=o.useState(O)[0],i=o.useState()[1],u=function(){return i([])},c=o.useRef(null);if(!c.current)var f=new r.Reaction(w(t),(function(){s.mounted?u():s.changedBeforeMount=!0})),s=m(c,f,n);var d,l,v=c.current.reaction;if(o.useDebugValue(v,a),o.useEffect((function(){return y(c),c.current?(c.current.mounted=!0,c.current.changedBeforeMount&&(c.current.changedBeforeMount=!1,u())):(c.current={reaction:new r.Reaction(w(t),(function(){u()})),mounted:!0,changedBeforeMount:!1,cleanAt:Infinity},u()),function(){c.current.reaction.dispose(),c.current=null}}),[]),v.track((function(){try{d=e()}catch(e){l=e}})),l)throw l;return d}var A={$$typeof:!0,render:!0,compare:!0,type:!0};function C(e){var r=e.children||e.render;return"function"!=typeof r?null:x(r)}function j(e){var n=t.useState((function(){return r.observable(e,{},{deep:!1})}))[0];return r.runInAction((function(){Object.assign(n,e)})),n}C.displayName="Observer",u(n.unstable_batchedUpdates),e.Observer=C,e.clearTimers=g,e.enableStaticRendering=T,e.isObserverBatched=function(){return!0},e.isUsingStaticRendering=R,e.observer=function(e,r){if(R())return e;var n,o,i,u=l({forwardRef:!1},r),a=e.displayName||e.name,c=function(r,t){return x((function(){return e(r,t)}),a)};return c.displayName=a,e.contextTypes&&(c.contextTypes=e.contextTypes),n=t.memo(u.forwardRef?t.forwardRef(c):c),o=e,i=n,Object.keys(o).forEach((function(e){A[e]||Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(o,e))})),n.displayName=a,n},e.observerBatching=u,e.useAsObservableSource=j,e.useLocalObservable=function(e,n){return t.useState((function(){return r.observable(e(),n,{autoBind:!0})}))[0]},e.useLocalStore=function(e,n){var o=n&&j(n);return t.useState((function(){return r.observable(e(o),void 0,{autoBind:!0})}))[0]},e.useObserver=function(e,r){return void 0===r&&(r="observed"),x(e,r)},e.useStaticRendering=function(e){T(e)},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=mobxreactlite.umd.production.min.js.map

@@ -27,2 +27,6 @@ var __assign = (this && this.__assign) || function () {

wrappedComponent.displayName = baseComponentName;
// Support legacy context: `contextTypes` must be applied before `memo`
if (baseComponent.contextTypes) {
wrappedComponent.contextTypes = baseComponent.contextTypes;
}
// memo; we are not interested in deep updates

@@ -44,2 +48,9 @@ // in props; we assume that if deep objects are changed,

memoComponent.displayName = baseComponentName;
if ("production" !== process.env.NODE_ENV) {
Object.defineProperty(memoComponent, 'contextTypes', {
set: function () {
throw new Error("[mobx-react-lite] `" + (this.displayName || 'Component') + ".contextTypes` must be set before applying `observer`.");
}
});
}
return memoComponent;

@@ -46,0 +57,0 @@ }

@@ -30,2 +30,6 @@ "use strict";

wrappedComponent.displayName = baseComponentName;
// Support legacy context: `contextTypes` must be applied before `memo`
if (baseComponent.contextTypes) {
wrappedComponent.contextTypes = baseComponent.contextTypes;
}
// memo; we are not interested in deep updates

@@ -47,2 +51,9 @@ // in props; we assume that if deep objects are changed,

memoComponent.displayName = baseComponentName;
if ("production" !== process.env.NODE_ENV) {
Object.defineProperty(memoComponent, 'contextTypes', {
set: function () {
throw new Error("[mobx-react-lite] `" + (this.displayName || 'Component') + ".contextTypes` must be set before applying `observer`.");
}
});
}
return memoComponent;

@@ -49,0 +60,0 @@ }

{
"name": "mobx-react-lite",
"version": "3.2.1",
"version": "3.2.2",
"description": "Lightweight React bindings for MobX based on React 16.8+ and Hooks",

@@ -53,3 +53,3 @@ "source": "src/index.ts",

"devDependencies": {
"mobx": "^6.3.3",
"mobx": "^6.3.6",
"expose-gc": "^1.0.0"

@@ -56,0 +56,0 @@ },

@@ -30,9 +30,9 @@ import { forwardRef, memo } from "react"

? C extends React.RefForwardingComponent<infer TRef, infer P>
? C &
React.MemoExoticComponent<
React.ForwardRefExoticComponent<
React.PropsWithoutRef<P> & React.RefAttributes<TRef>
>
>
: never /* forwardRef set for a non forwarding component */
? C &
React.MemoExoticComponent<
React.ForwardRefExoticComponent<
React.PropsWithoutRef<P> & React.RefAttributes<TRef>
>
>
: never /* forwardRef set for a non forwarding component */
: C & { displayName: string }

@@ -62,2 +62,7 @@

// Support legacy context: `contextTypes` must be applied before `memo`
if ((baseComponent as any).contextTypes) {
wrappedComponent.contextTypes = (baseComponent as any).contextTypes;
}
// memo; we are not interested in deep updates

@@ -80,2 +85,10 @@ // in props; we assume that if deep objects are changed,

if ("production" !== process.env.NODE_ENV) {
Object.defineProperty(memoComponent, 'contextTypes', {
set() {
throw new Error(`[mobx-react-lite] \`${this.displayName || 'Component'}.contextTypes\` must be set before applying \`observer\`.`);
}
})
}
return memoComponent

@@ -82,0 +95,0 @@ }

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc