New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 2.2.0-beta.0 to 2.2.0

2

batchingForReactDom.js
if ("production" !== process.env.NODE_ENV) {
console.warn("[mobx-react-lite] calling batchingForReactDom is no longer needed")
console.warn("[mobx-react-lite] importing batchingForReactDom is no longer needed")
}
if ("production" !== process.env.NODE_ENV) {
console.warn("[mobx-react-lite] calling batchingForReactNative is no longer needed")
console.warn("[mobx-react-lite] importing batchingForReactNative is no longer needed")
}
if ("production" !== process.env.NODE_ENV) {
console.warn("[mobx-react-lite] calling batchingOptOut is no longer needed")
console.warn("[mobx-react-lite] importing batchingOptOut is no longer needed")
}

@@ -10,1 +10,2 @@ import "./assertEnvironment";

export { useQueuedForceUpdate, useQueuedForceUpdateBlock } from "./useQueuedForceUpdate";
export { observerBatching } from "./observerBatching";

@@ -20,3 +20,3 @@ (function (global, factory) {

}
function setBatch(reactionScheduler) {
function observerBatching(reactionScheduler) {
if (!reactionScheduler) {

@@ -466,3 +466,3 @@ reactionScheduler = defaulNoopBatch;

setBatch(reactDom.unstable_batchedUpdates);
observerBatching(reactDom.unstable_batchedUpdates);

@@ -472,2 +472,3 @@ exports.Observer = ObserverComponent;

exports.observer = observer;
exports.observerBatching = observerBatching;
exports.useAsObservableSource = useAsObservableSource;

@@ -474,0 +475,0 @@ exports.useForceUpdate = useForceUpdate;

@@ -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.spy)throw new Error("mobx-react-lite requires mobx at least version 4 to be available");var u=!1;function c(){return u}function i(){return(i=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 a(e){return r.getDependencyTree(e)}var f,s=new Set;function d(){void 0===f&&(f=setTimeout(l,1e4))}function l(){f=void 0;var e=Date.now();s.forEach((function(r){var n=r.current;n&&e>=n.cleanAt&&(n.reaction.dispose(),r.current=null,s.delete(r))})),s.size>0&&d()}function p(){var e=n.useState(0)[1];return n.useCallback((function(){e((function(e){return e+1}))}),[])}var v=!1,b=[];function y(e){return function(){v?b.push(e):e()}}function h(e){v=!0,b=[];try{var r=e();v=!1;var n=b.length>0?b:void 0;return o.useLayoutEffect((function(){n&&n.forEach((function(e){return e()}))}),[n]),r}finally{v=!1}}var m={};function w(e){return"observer"+e}function O(e,n,t){if(void 0===n&&(n="observed"),void 0===t&&(t=m),c())return e();var u=y((t.useForceUpdate||p)()),i=o.useRef(null);if(!i.current){var f=new r.Reaction(w(n),(function(){l.mounted?u():(f.dispose(),i.current=null)})),l=function(e){return{cleanAt:Date.now()+1e4,reaction:e}}(f);i.current=l,s.add(i),d()}var v=i.current.reaction;return o.useDebugValue(v,a),o.useEffect((function(){return s.delete(i),i.current?i.current.mounted=!0:(i.current={reaction:new r.Reaction(w(n),(function(){u()})),cleanAt:Infinity},u()),function(){i.current.reaction.dispose(),i.current=null}}),[]),h((function(){var r,n;if(v.track((function(){try{r=e()}catch(e){n=e}})),n)throw n;return r}))}var g,j={$$typeof:!0,render:!0,compare:!0,type:!0};function R(e){var r=e.children||e.render;return"function"!=typeof r?null:O(r)}function x(e,r,n,t,o){var u="function"==typeof e[r],c="function"==typeof e["children"===r?"render":"children"];return u&&c?new Error("MobX Observer: Do not use children and render in the same time in`"+n):u||c?null:new Error("Invalid prop `"+o+"` of type `"+typeof e[r]+"` supplied to `"+n+"`, expected `function`.")}function E(e,n){if(!n||void 0!==e){var t=o.useState((function(){return r.observable(e,{},{deep:!1})}))[0];return r.runInAction((function(){Object.assign(t,e)})),t}}R.propTypes={children:x,render:x},R.displayName="Observer",(g=t.unstable_batchedUpdates)||(g=function(e){e()}),r.configure({reactionScheduler:g}),e.Observer=R,e.isUsingStaticRendering=c,e.observer=function(e,r){if(c())return e;var t,o,u,a=i({forwardRef:!1},r),f=e.displayName||e.name,s=function(r,n){return O((function(){return e(r,n)}),f)};return s.displayName=f,t=n.memo(a.forwardRef?n.forwardRef(s):s),o=e,u=t,Object.keys(o).forEach((function(e){j[e]||Object.defineProperty(u,e,Object.getOwnPropertyDescriptor(o,e))})),t.displayName=f,t},e.useAsObservableSource=function(e){return E(e,!1)},e.useForceUpdate=p,e.useLocalStore=function(e,n){var t=E(n,!0);return o.useState((function(){var n=r.observable(e(t));return function(e){if(!e||"object"!=typeof e)return!1;var r=Object.getPrototypeOf(e);return!r||r===Object.prototype}(n)&&r.runInAction((function(){Object.keys(n).forEach((function(e){var t,o,u=n[e];"function"==typeof u&&(n[e]=(t=u,o=n,function(){for(var e=arguments.length,n=new Array(e),u=0;u<e;u++)n[u]=arguments[u];return r.transaction((function(){return t.apply(o,n)}))}))}))})),n}))[0]},e.useObserver=O,e.useQueuedForceUpdate=y,e.useQueuedForceUpdateBlock=h,e.useStaticRendering=function(e){u=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,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.spy)throw new Error("mobx-react-lite requires mobx at least version 4 to be available");function u(e){e()}function c(e){e||(e=u),r.configure({reactionScheduler:e})}var i=!1;function a(){return i}function f(){return(f=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 s(e){return r.getDependencyTree(e)}var d,l=new Set;function p(){void 0===d&&(d=setTimeout(v,1e4))}function v(){d=void 0;var e=Date.now();l.forEach((function(r){var n=r.current;n&&e>=n.cleanAt&&(n.reaction.dispose(),r.current=null,l.delete(r))})),l.size>0&&p()}function b(){var e=n.useState(0)[1];return n.useCallback((function(){e((function(e){return e+1}))}),[])}var y=!1,h=[];function m(e){return function(){y?h.push(e):e()}}function w(e){y=!0,h=[];try{var r=e();y=!1;var n=h.length>0?h:void 0;return o.useLayoutEffect((function(){n&&n.forEach((function(e){return e()}))}),[n]),r}finally{y=!1}}var O={};function g(e){return"observer"+e}function j(e,n,t){if(void 0===n&&(n="observed"),void 0===t&&(t=O),a())return e();var u=m((t.useForceUpdate||b)()),c=o.useRef(null);if(!c.current){var i=new r.Reaction(g(n),(function(){f.mounted?u():(i.dispose(),c.current=null)})),f=function(e){return{cleanAt:Date.now()+1e4,reaction:e}}(i);c.current=f,l.add(c),p()}var d=c.current.reaction;return o.useDebugValue(d,s),o.useEffect((function(){return l.delete(c),c.current?c.current.mounted=!0:(c.current={reaction:new r.Reaction(g(n),(function(){u()})),cleanAt:Infinity},u()),function(){c.current.reaction.dispose(),c.current=null}}),[]),w((function(){var r,n;if(d.track((function(){try{r=e()}catch(e){n=e}})),n)throw n;return r}))}var R={$$typeof:!0,render:!0,compare:!0,type:!0};function x(e){var r=e.children||e.render;return"function"!=typeof r?null:j(r)}function E(e,r,n,t,o){var u="function"==typeof e[r],c="function"==typeof e["children"===r?"render":"children"];return u&&c?new Error("MobX Observer: Do not use children and render in the same time in`"+n):u||c?null:new Error("Invalid prop `"+o+"` of type `"+typeof e[r]+"` supplied to `"+n+"`, expected `function`.")}function S(e,n){if(!n||void 0!==e){var t=o.useState((function(){return r.observable(e,{},{deep:!1})}))[0];return r.runInAction((function(){Object.assign(t,e)})),t}}x.propTypes={children:E,render:E},x.displayName="Observer",c(t.unstable_batchedUpdates),e.Observer=x,e.isUsingStaticRendering=a,e.observer=function(e,r){if(a())return e;var t,o,u,c=f({forwardRef:!1},r),i=e.displayName||e.name,s=function(r,n){return j((function(){return e(r,n)}),i)};return s.displayName=i,t=n.memo(c.forwardRef?n.forwardRef(s):s),o=e,u=t,Object.keys(o).forEach((function(e){R[e]||Object.defineProperty(u,e,Object.getOwnPropertyDescriptor(o,e))})),t.displayName=i,t},e.observerBatching=c,e.useAsObservableSource=function(e){return S(e,!1)},e.useForceUpdate=b,e.useLocalStore=function(e,n){var t=S(n,!0);return o.useState((function(){var n=r.observable(e(t));return function(e){if(!e||"object"!=typeof e)return!1;var r=Object.getPrototypeOf(e);return!r||r===Object.prototype}(n)&&r.runInAction((function(){Object.keys(n).forEach((function(e){var t,o,u=n[e];"function"==typeof u&&(n[e]=(t=u,o=n,function(){for(var e=arguments.length,n=new Array(e),u=0;u<e;u++)n[u]=arguments[u];return r.transaction((function(){return t.apply(o,n)}))}))}))})),n}))[0]},e.useObserver=j,e.useQueuedForceUpdate=m,e.useQueuedForceUpdateBlock=w,e.useStaticRendering=function(e){i=e},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=mobxreactlite.umd.production.min.js.map
export declare function defaulNoopBatch(callback: () => void): void;
export declare function setBatch(reactionScheduler: any): void;
export declare function observerBatching(reactionScheduler: any): void;
/// <reference types="react" />
interface IObserverProps {
children?(): React.ReactElement<any>;
render?(): React.ReactElement<any>;
children?(): React.ReactElement | null;
render?(): React.ReactElement | null;
}

@@ -6,0 +6,0 @@ declare function ObserverComponent({ children, render }: IObserverProps): import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)> | null;

import "./assertEnvironment";
import { unstable_batchedUpdates as batch } from "./utils/reactBatchedUpdates";
import { setBatch } from "./observerBatching";
setBatch(batch);
import { observerBatching } from "./observerBatching";
observerBatching(batch);
export { isUsingStaticRendering, useStaticRendering } from "./staticRendering";

@@ -13,1 +13,2 @@ export { observer } from "./observer";

export { useQueuedForceUpdate, useQueuedForceUpdateBlock } from "./useQueuedForceUpdate";
export { observerBatching } from "./observerBatching";

@@ -5,3 +5,3 @@ import { configure } from "mobx";

}
export function setBatch(reactionScheduler) {
export function observerBatching(reactionScheduler) {
if (!reactionScheduler) {

@@ -8,0 +8,0 @@ reactionScheduler = defaulNoopBatch;

@@ -6,3 +6,3 @@ "use strict";

var observerBatching_1 = require("./observerBatching");
observerBatching_1.setBatch(reactBatchedUpdates_1.unstable_batchedUpdates);
observerBatching_1.observerBatching(reactBatchedUpdates_1.unstable_batchedUpdates);
var staticRendering_1 = require("./staticRendering");

@@ -26,1 +26,3 @@ exports.isUsingStaticRendering = staticRendering_1.isUsingStaticRendering;

exports.useQueuedForceUpdateBlock = useQueuedForceUpdate_1.useQueuedForceUpdateBlock;
var observerBatching_2 = require("./observerBatching");
exports.observerBatching = observerBatching_2.observerBatching;

@@ -8,3 +8,3 @@ "use strict";

exports.defaulNoopBatch = defaulNoopBatch;
function setBatch(reactionScheduler) {
function observerBatching(reactionScheduler) {
if (!reactionScheduler) {

@@ -18,2 +18,2 @@ reactionScheduler = defaulNoopBatch;

}
exports.setBatch = setBatch;
exports.observerBatching = observerBatching;
{
"name": "mobx-react-lite",
"version": "2.2.0-beta.0",
"version": "2.2.0",
"description": "Lightweight React bindings for MobX based on React 16.8+ and Hooks",
"main": "lib/index.js",
"unpkg": "dist/mobxreactlite.umd.production.min.js",
"jsdelivr": "dist/mobxreactlite.umd.production.min.js",
"module": "es/index.js",
"jsnext:main": "es/index.js",
"react-native": "es/index.js",
"types": "dist/index.d.ts",

@@ -110,2 +113,2 @@ "sideEffects": [

"dependencies": {}
}
}

@@ -64,2 +64,4 @@ # mobx-react-lite

_Note: configuring observer batching is only needed when using `mobx-react-lite` 2.0.* or 2.1.*. From 2.2 onward it will be configured automatically based on the availability of react-dom / react-native packages_
[Check out the elaborate explanation](https://github.com/mobxjs/mobx-react/pull/787#issuecomment-573599793).

@@ -66,0 +68,0 @@

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