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.0.0-beta.1 to 3.0.0

5

dist/index.d.ts
import "./utils/assertEnvironment";
export { isUsingStaticRendering, useStaticRendering } from "./staticRendering";
export { isUsingStaticRendering, enableStaticRendering } from "./staticRendering";
export { observer, IObserverOptions } from "./observer";
export { Observer } from "./ObserverComponent";
export { useLocalObservable } from "./useLocalObservable";
export { observerBatching } from "./utils/observerBatching";
export { useLocalStore } from "./useLocalStore";
export { useAsObservableSource } from "./useAsObservableSource";
export declare function useObserver<T>(fn: () => T, baseComponentName?: string): T;
export { isObserverBatched, observerBatching } from "./utils/observerBatching";
export declare function useStaticRendering(enable: boolean): void;

22

dist/mobxreactlite.umd.development.js

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

function defaulNoopBatch(callback) {
function defaultNoopBatch(callback) {
callback();

@@ -23,3 +23,3 @@ }

if (!reactionScheduler) {
reactionScheduler = defaulNoopBatch;
reactionScheduler = defaultNoopBatch;

@@ -35,3 +35,10 @@ {

}
var isObserverBatched = function isObserverBatched() {
{
console.warn("[MobX] Deprecated");
}
return true;
};
var EMPTY_ARRAY = [];

@@ -137,3 +144,3 @@ function useForceUpdate() {

var globalIsUsingStaticRendering = false;
function useStaticRendering(enable) {
function enableStaticRendering(enable) {
globalIsUsingStaticRendering = enable;

@@ -397,4 +404,13 @@ }

}
function useStaticRendering(enable) {
{
console.warn("[mobx-react-lite] 'useStaticRendering' is deprecated, use 'enableStaticRendering' instead");
}
enableStaticRendering(enable);
}
exports.Observer = ObserverComponent;
exports.enableStaticRendering = enableStaticRendering;
exports.isObserverBatched = isObserverBatched;
exports.isUsingStaticRendering = isUsingStaticRendering;

@@ -401,0 +417,0 @@ exports.observer = observer;

@@ -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,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 u(e){e()}function i(e){e||(e=u),r.configure({reactionScheduler:e})}var c=[];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 t=r.current;t&&e>=t.cleanAt&&(t.reaction.dispose(),r.current=null,s.delete(r))})),s.size>0&&d()}var b=!1;function v(){return b}function p(e){return"observer"+e}function m(e,n){if(void 0===n&&(n="observed"),v())return e();var u,i=(u=t.useState(0)[1],t.useCallback((function(){u((function(e){return e+1}))}),c)),f=o.useRef(null);if(!f.current){var l=new r.Reaction(p(n),(function(){b.mounted?i():(l.dispose(),f.current=null)})),b=function(e){return{cleanAt:Date.now()+1e4,reaction:e}}(l);f.current=b,s.add(f),d()}var m,y,w=f.current.reaction;if(o.useDebugValue(w,a),o.useEffect((function(){return s.delete(f),f.current?f.current.mounted=!0:(f.current={reaction:new r.Reaction(p(n),(function(){i()})),cleanAt:Infinity},i()),function(){f.current.reaction.dispose(),f.current=null}}),[]),w.track((function(){try{m=e()}catch(e){y=e}})),y)throw y;return m}function y(){return(y=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 w={$$typeof:!0,render:!0,compare:!0,type:!0};function O(e){var r=e.children||e.render;return"function"!=typeof r?null:m(r)}function h(e){var n=t.useState((function(){return r.observable(e,{},{deep:!1})}))[0];return r.runInAction((function(){Object.assign(n,e)})),n}O.displayName="Observer",i(n.unstable_batchedUpdates),e.Observer=O,e.isUsingStaticRendering=v,e.observer=function(e,r){if(v())return e;var n,o,u,i=y({forwardRef:!1},r),c=e.displayName||e.name,a=function(r,t){return m((function(){return e(r,t)}),c)};return a.displayName=c,n=t.memo(i.forwardRef?t.forwardRef(a):a),o=e,u=n,Object.keys(o).forEach((function(e){w[e]||Object.defineProperty(u,e,Object.getOwnPropertyDescriptor(o,e))})),n.displayName=c,n},e.observerBatching=i,e.useAsObservableSource=h,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&&h(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"),m(e,r)},e.useStaticRendering=function(e){b=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 u(e){e()}function i(e){e||(e=u),r.configure({reactionScheduler:e})}var c=[];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 t=r.current;t&&e>=t.cleanAt&&(t.reaction.dispose(),r.current=null,s.delete(r))})),s.size>0&&d()}var b=!1;function v(e){b=e}function p(){return b}function m(e){return"observer"+e}function y(e,n){if(void 0===n&&(n="observed"),p())return e();var u,i=(u=t.useState(0)[1],t.useCallback((function(){u((function(e){return e+1}))}),c)),f=o.useRef(null);if(!f.current){var l=new r.Reaction(m(n),(function(){b.mounted?i():(l.dispose(),f.current=null)})),b=function(e){return{cleanAt:Date.now()+1e4,reaction:e}}(l);f.current=b,s.add(f),d()}var v,y,O=f.current.reaction;if(o.useDebugValue(O,a),o.useEffect((function(){return s.delete(f),f.current?f.current.mounted=!0:(f.current={reaction:new r.Reaction(m(n),(function(){i()})),cleanAt:Infinity},i()),function(){f.current.reaction.dispose(),f.current=null}}),[]),O.track((function(){try{v=e()}catch(e){y=e}})),y)throw y;return v}function O(){return(O=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 h={$$typeof:!0,render:!0,compare:!0,type:!0};function w(e){var r=e.children||e.render;return"function"!=typeof r?null:y(r)}function R(e){var n=t.useState((function(){return r.observable(e,{},{deep:!1})}))[0];return r.runInAction((function(){Object.assign(n,e)})),n}w.displayName="Observer",i(n.unstable_batchedUpdates),e.Observer=w,e.enableStaticRendering=v,e.isObserverBatched=function(){return!0},e.isUsingStaticRendering=p,e.observer=function(e,r){if(p())return e;var n,o,u,i=O({forwardRef:!1},r),c=e.displayName||e.name,a=function(r,t){return y((function(){return e(r,t)}),c)};return a.displayName=c,n=t.memo(i.forwardRef?t.forwardRef(a):a),o=e,u=n,Object.keys(o).forEach((function(e){h[e]||Object.defineProperty(u,e,Object.getOwnPropertyDescriptor(o,e))})),n.displayName=c,n},e.observerBatching=i,e.useAsObservableSource=R,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&&R(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"),y(e,r)},e.useStaticRendering=function(e){v(e)},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=mobxreactlite.umd.production.min.js.map

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

export declare function useStaticRendering(enable: boolean): void;
export declare function enableStaticRendering(enable: boolean): void;
export declare function isUsingStaticRendering(): boolean;

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

export declare function defaulNoopBatch(callback: () => void): void;
export declare function defaultNoopBatch(callback: () => void): void;
export declare function observerBatching(reactionScheduler: any): void;
export declare const isObserverBatched: () => boolean;

@@ -6,8 +6,8 @@ import "./utils/assertEnvironment";

import { useObserver as useObserverOriginal } from "./useObserver";
import { enableStaticRendering } from "./staticRendering";
observerBatching(batch);
export { isUsingStaticRendering, useStaticRendering } from "./staticRendering";
export { isUsingStaticRendering, enableStaticRendering } from "./staticRendering";
export { observer } from "./observer";
export { Observer } from "./ObserverComponent";
export { useLocalObservable } from "./useLocalObservable";
export { observerBatching } from "./utils/observerBatching";
export { useLocalStore } from "./useLocalStore";

@@ -22,1 +22,8 @@ export { useAsObservableSource } from "./useAsObservableSource";

}
export { isObserverBatched, observerBatching } from "./utils/observerBatching";
export function useStaticRendering(enable) {
if ("production" !== process.env.NODE_ENV) {
console.warn("[mobx-react-lite] 'useStaticRendering' is deprecated, use 'enableStaticRendering' instead");
}
enableStaticRendering(enable);
}
var globalIsUsingStaticRendering = false;
export function useStaticRendering(enable) {
export function enableStaticRendering(enable) {
globalIsUsingStaticRendering = enable;

@@ -4,0 +4,0 @@ }

import { configure } from "mobx";
export function defaulNoopBatch(callback) {
export function defaultNoopBatch(callback) {
callback();

@@ -7,3 +7,3 @@ }

if (!reactionScheduler) {
reactionScheduler = defaulNoopBatch;
reactionScheduler = defaultNoopBatch;
if ("production" !== process.env.NODE_ENV) {

@@ -15,1 +15,7 @@ console.warn("[MobX] Failed to get unstable_batched updates from react-dom / react-native");

}
export var isObserverBatched = function () {
if ("production" !== process.env.NODE_ENV) {
console.warn("[MobX] Deprecated");
}
return true;
};

@@ -8,6 +8,7 @@ "use strict";

var useObserver_1 = require("./useObserver");
var staticRendering_1 = require("./staticRendering");
observerBatching_1.observerBatching(reactBatchedUpdates_1.unstable_batchedUpdates);
var staticRendering_1 = require("./staticRendering");
exports.isUsingStaticRendering = staticRendering_1.isUsingStaticRendering;
exports.useStaticRendering = staticRendering_1.useStaticRendering;
var staticRendering_2 = require("./staticRendering");
exports.isUsingStaticRendering = staticRendering_2.isUsingStaticRendering;
exports.enableStaticRendering = staticRendering_2.enableStaticRendering;
var observer_1 = require("./observer");

@@ -19,4 +20,2 @@ exports.observer = observer_1.observer;

exports.useLocalObservable = useLocalObservable_1.useLocalObservable;
var observerBatching_2 = require("./utils/observerBatching");
exports.observerBatching = observerBatching_2.observerBatching;
var useLocalStore_1 = require("./useLocalStore");

@@ -34,1 +33,11 @@ exports.useLocalStore = useLocalStore_1.useLocalStore;

exports.useObserver = useObserver;
var observerBatching_2 = require("./utils/observerBatching");
exports.isObserverBatched = observerBatching_2.isObserverBatched;
exports.observerBatching = observerBatching_2.observerBatching;
function useStaticRendering(enable) {
if ("production" !== process.env.NODE_ENV) {
console.warn("[mobx-react-lite] 'useStaticRendering' is deprecated, use 'enableStaticRendering' instead");
}
staticRendering_1.enableStaticRendering(enable);
}
exports.useStaticRendering = useStaticRendering;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var globalIsUsingStaticRendering = false;
function useStaticRendering(enable) {
function enableStaticRendering(enable) {
globalIsUsingStaticRendering = enable;
}
exports.useStaticRendering = useStaticRendering;
exports.enableStaticRendering = enableStaticRendering;
function isUsingStaticRendering() {

@@ -9,0 +9,0 @@ return globalIsUsingStaticRendering;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var mobx_1 = require("mobx");
function defaulNoopBatch(callback) {
function defaultNoopBatch(callback) {
callback();
}
exports.defaulNoopBatch = defaulNoopBatch;
exports.defaultNoopBatch = defaultNoopBatch;
function observerBatching(reactionScheduler) {
if (!reactionScheduler) {
reactionScheduler = defaulNoopBatch;
reactionScheduler = defaultNoopBatch;
if ("production" !== process.env.NODE_ENV) {

@@ -18,1 +18,7 @@ console.warn("[MobX] Failed to get unstable_batched updates from react-dom / react-native");

exports.observerBatching = observerBatching;
exports.isObserverBatched = function () {
if ("production" !== process.env.NODE_ENV) {
console.warn("[MobX] Deprecated");
}
return true;
};
{
"name": "mobx-react-lite",
"version": "3.0.0-beta.1",
"version": "3.0.0",
"description": "Lightweight React bindings for MobX based on React 16.8+ and Hooks",

@@ -12,5 +12,2 @@ "main": "lib/index.js",

"types": "dist/index.d.ts",
"sideEffects": [
"batching*"
],
"repository": {

@@ -114,2 +111,2 @@ "type": "git",

"dependencies": {}
}
}

@@ -50,5 +50,5 @@ # mobx-react-lite

### **`useStaticRendering(enable: true)`**
### **`enableStaticRendering(enable: true)`**
Call `useStaticRendering(true)` when running in an SSR environment, in which `observer` wrapped components should never re-render, but cleanup after the first rendering automatically. Use `isUsingStaticRendering()` to inspect the current setting.
Call `enableStaticRendering(true)` when running in an SSR environment, in which `observer` wrapped components should never re-render, but cleanup after the first rendering automatically. Use `isUsingStaticRendering()` to inspect the current setting.

@@ -55,0 +55,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