New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tamagui/use-controllable-state

Package Overview
Dependencies
Maintainers
1
Versions
1225
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tamagui/use-controllable-state - npm Package Compare versions

Comparing version 1.125.6 to 1.125.7

4

dist/esm/index.native.js

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

export * from "./useControllableState";
//# sourceMappingURL=index.js.map
export * from "./useControllableState.native.js";
//# sourceMappingURL=index.native.js.map
import { useEvent } from "@tamagui/use-event";
import * as React from "react";
import { startTransition } from "@tamagui/start-transition";
var emptyCallbackFn = function(_) {
var emptyCallbackFn = function (_) {
return _();
};
function useControllableState(param) {
var { prop, defaultProp, onChange, strategy = "prop-wins", preventUpdate, transition } = param, [state, setState] = React.useState(prop ?? defaultProp), previous = React.useRef(state), propWins = strategy === "prop-wins" && prop !== void 0, value = propWins ? prop : state, onChangeCb = useEvent(onChange || idFn), transitionFn = transition ? startTransition : emptyCallbackFn;
React.useEffect(function() {
prop !== void 0 && (previous.current = prop, transitionFn(function() {
var {
prop,
defaultProp,
onChange,
strategy = "prop-wins",
preventUpdate,
transition
} = param,
[state, setState] = React.useState(prop ?? defaultProp),
previous = React.useRef(state),
propWins = strategy === "prop-wins" && prop !== void 0,
value = propWins ? prop : state,
onChangeCb = useEvent(onChange || idFn),
transitionFn = transition ? startTransition : emptyCallbackFn;
React.useEffect(function () {
prop !== void 0 && (previous.current = prop, transitionFn(function () {
setState(prop);
}));
}, [
prop
]), React.useEffect(function() {
}, [prop]), React.useEffect(function () {
propWins || state !== previous.current && (previous.current = state, onChangeCb(state));
}, [
onChangeCb,
state,
propWins
]);
var setter = useEvent(function(next) {
if (!preventUpdate)
if (propWins) {
var nextValue = typeof next == "function" ? next(previous.current) : next;
onChangeCb(nextValue);
} else
transitionFn(function() {
setState(next);
});
}, [onChangeCb, state, propWins]);
var setter = useEvent(function (next) {
if (!preventUpdate) if (propWins) {
var nextValue = typeof next == "function" ? next(previous.current) : next;
onChangeCb(nextValue);
} else transitionFn(function () {
setState(next);
});
});
return [
value,
setter
];
return [value, setter];
}
var idFn = function() {
};
export {
useControllableState
};
//# sourceMappingURL=useControllableState.js.map
var idFn = function () {};
export { useControllableState };
//# sourceMappingURL=useControllableState.native.js.map
{
"name": "@tamagui/use-controllable-state",
"version": "1.125.6",
"version": "1.125.7",
"sideEffects": false,

@@ -36,7 +36,7 @@ "source": "src/index.ts",

"dependencies": {
"@tamagui/start-transition": "1.125.6",
"@tamagui/use-event": "1.125.6"
"@tamagui/start-transition": "1.125.7",
"@tamagui/use-event": "1.125.7"
},
"devDependencies": {
"@tamagui/build": "1.125.6",
"@tamagui/build": "1.125.7",
"react": "*"

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