Socket
Socket
Sign inDemoInstall

@tamagui/react-native-use-responder-events

Package Overview
Dependencies
Maintainers
0
Versions
885
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tamagui/react-native-use-responder-events - npm Package Compare versions

Comparing version 1.112.4 to 1.112.5

16

dist/cjs/useResponderEvents.js

@@ -29,8 +29,8 @@ var __create = Object.create;

__reExport(useResponderEvents_exports, require("./utils"), module.exports);
const emptyObject = {};
const emptyObject = {}, Attached = /* @__PURE__ */ new WeakMap(), Ids = /* @__PURE__ */ new WeakMap();
function useResponderEvents(hostRef, config = emptyObject) {
const id = React.useId(), isAttachedRef = React.useRef(!1);
React.useEffect(() => (ResponderSystem.attachListeners(), () => {
ResponderSystem.removeNode(id);
}), [id]), React.useEffect(() => {
Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
const id = Ids.get(hostRef);
React.useEffect(() => {
ResponderSystem.attachListeners();
const {

@@ -46,3 +46,7 @@ onMoveShouldSetResponder,

} = config, requiresResponderSystem = !!(onMoveShouldSetResponder || onMoveShouldSetResponderCapture || onScrollShouldSetResponder || onScrollShouldSetResponderCapture || onSelectionChangeShouldSetResponder || onSelectionChangeShouldSetResponderCapture || onStartShouldSetResponder || onStartShouldSetResponderCapture), node = hostRef.current.host;
requiresResponderSystem ? (ResponderSystem.addNode(id, node, config), isAttachedRef.current = !0) : isAttachedRef.current && (ResponderSystem.removeNode(id), isAttachedRef.current = !1);
if (requiresResponderSystem)
return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), () => {
ResponderSystem.removeNode(node);
};
Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
}, [config, hostRef, id]), process.env.NODE_ENV === "development" && (React.useDebugValue({

@@ -49,0 +53,0 @@ isResponder: hostRef.current === ResponderSystem.getResponderNode()

@@ -30,14 +30,15 @@ "use strict";

__reExport(useResponderEvents_exports, require("./utils"), module.exports);
var emptyObject = {};
var emptyObject = {}, Attached = /* @__PURE__ */ new WeakMap(), Ids = /* @__PURE__ */ new WeakMap();
function useResponderEvents(hostRef) {
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : emptyObject, id = React.useId(), isAttachedRef = React.useRef(!1);
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : emptyObject;
Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
var id = Ids.get(hostRef);
React.useEffect(function() {
return ResponderSystem.attachListeners(), function() {
ResponderSystem.removeNode(id);
};
}, [
id
]), React.useEffect(function() {
ResponderSystem.attachListeners();
var { onMoveShouldSetResponder, onMoveShouldSetResponderCapture, onScrollShouldSetResponder, onScrollShouldSetResponderCapture, onSelectionChangeShouldSetResponder, onSelectionChangeShouldSetResponderCapture, onStartShouldSetResponder, onStartShouldSetResponderCapture } = config, requiresResponderSystem = !!(onMoveShouldSetResponder || onMoveShouldSetResponderCapture || onScrollShouldSetResponder || onScrollShouldSetResponderCapture || onSelectionChangeShouldSetResponder || onSelectionChangeShouldSetResponderCapture || onStartShouldSetResponder || onStartShouldSetResponderCapture), node = hostRef.current.host;
requiresResponderSystem ? (ResponderSystem.addNode(id, node, config), isAttachedRef.current = !0) : isAttachedRef.current && (ResponderSystem.removeNode(id), isAttachedRef.current = !1);
if (requiresResponderSystem)
return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), function() {
ResponderSystem.removeNode(node);
};
Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
}, [

@@ -44,0 +45,0 @@ config,

import * as React from "react";
import * as ResponderSystem from "./ResponderSystem";
export * from "./utils";
const emptyObject = {};
const emptyObject = {}, Attached = /* @__PURE__ */ new WeakMap(), Ids = /* @__PURE__ */ new WeakMap();
function useResponderEvents(hostRef, config = emptyObject) {
const id = React.useId(), isAttachedRef = React.useRef(!1);
React.useEffect(() => (ResponderSystem.attachListeners(), () => {
ResponderSystem.removeNode(id);
}), [id]), React.useEffect(() => {
Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
const id = Ids.get(hostRef);
React.useEffect(() => {
ResponderSystem.attachListeners();
const {

@@ -20,3 +20,7 @@ onMoveShouldSetResponder,

} = config, requiresResponderSystem = !!(onMoveShouldSetResponder || onMoveShouldSetResponderCapture || onScrollShouldSetResponder || onScrollShouldSetResponderCapture || onSelectionChangeShouldSetResponder || onSelectionChangeShouldSetResponderCapture || onStartShouldSetResponder || onStartShouldSetResponderCapture), node = hostRef.current.host;
requiresResponderSystem ? (ResponderSystem.addNode(id, node, config), isAttachedRef.current = !0) : isAttachedRef.current && (ResponderSystem.removeNode(id), isAttachedRef.current = !1);
if (requiresResponderSystem)
return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), () => {
ResponderSystem.removeNode(node);
};
Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
}, [config, hostRef, id]), process.env.NODE_ENV === "development" && (React.useDebugValue({

@@ -23,0 +27,0 @@ isResponder: hostRef.current === ResponderSystem.getResponderNode()

import * as React from "react";
import * as ResponderSystem from "./ResponderSystem.native.js";
export * from "./utils.native.js";
var emptyObject = {};
var emptyObject = {},
Attached = /* @__PURE__ */new WeakMap(),
Ids = /* @__PURE__ */new WeakMap();
function useResponderEvents(hostRef) {
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : emptyObject,
id = React.useId(),
isAttachedRef = React.useRef(!1);
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : emptyObject;
Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
var id = Ids.get(hostRef);
React.useEffect(function () {
return ResponderSystem.attachListeners(), function () {
ResponderSystem.removeNode(id);
};
}, [id]), React.useEffect(function () {
ResponderSystem.attachListeners();
var {

@@ -26,3 +25,6 @@ onMoveShouldSetResponder,

node = hostRef.current.host;
requiresResponderSystem ? (ResponderSystem.addNode(id, node, config), isAttachedRef.current = !0) : isAttachedRef.current && (ResponderSystem.removeNode(id), isAttachedRef.current = !1);
if (requiresResponderSystem) return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), function () {
ResponderSystem.removeNode(node);
};
Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
}, [config, hostRef, id]), process.env.NODE_ENV === "development" && (React.useDebugValue({

@@ -29,0 +31,0 @@ isResponder: hostRef.current === ResponderSystem.getResponderNode()

{
"name": "@tamagui/react-native-use-responder-events",
"version": "1.112.4",
"version": "1.112.5",
"types": "./types/index.d.ts",

@@ -31,3 +31,3 @@ "main": "dist/cjs",

"devDependencies": {
"@tamagui/build": "1.112.4",
"@tamagui/build": "1.112.5",
"react": "^18.2.0 || ^19.0.0"

@@ -34,0 +34,0 @@ },

@@ -15,2 +15,5 @@ /**

const Attached = new WeakMap<any, boolean>()
const Ids = new WeakMap<any, string>()
export function useResponderEvents(

@@ -20,17 +23,11 @@ hostRef: any,

) {
const id = React.useId()
const isAttachedRef = React.useRef(false)
if (!Ids.has(hostRef)) {
Ids.set(hostRef, `${Math.random()}`)
}
const id = Ids.get(hostRef)!
// This is a separate effects so it doesn't run when the config changes.
// On initial mount, attach global listeners if needed.
// On unmount, remove node potentially attached to the Responder System.
// Register and unregister with the Responder System as necessary
React.useEffect(() => {
ResponderSystem.attachListeners()
return () => {
ResponderSystem.removeNode(id)
}
}, [id])
// Register and unregister with the Responder System as necessary
React.useEffect(() => {
const {

@@ -62,7 +59,13 @@ onMoveShouldSetResponder,

ResponderSystem.addNode(id, node, config)
isAttachedRef.current = true
} else if (isAttachedRef.current) {
ResponderSystem.removeNode(id)
isAttachedRef.current = false
Attached.set(hostRef, true)
return () => {
ResponderSystem.removeNode(node)
}
}
if (Attached.get(node)) {
ResponderSystem.removeNode(node)
Attached.set(hostRef, false)
}
}, [config, hostRef, id])

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

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