Socket
Socket
Sign inDemoInstall

@chakra-ui/hooks

Package Overview
Dependencies
Maintainers
4
Versions
401
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chakra-ui/hooks - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

12

CHANGELOG.md
# Change Log
## 1.1.1
### Patch Changes
- [`02855588`](https://github.com/chakra-ui/chakra-ui/commit/02855588a4ffbc6573768052e53cc538361e91ee)
[#3056](https://github.com/chakra-ui/chakra-ui/pull/3056) Thanks
[@with-heart](https://github.com/with-heart)! - - Resolved an issue where
event handlers for certain components were removed after the first event
occurred.
- Fixed SSR issue with `useId` hook
## 1.1.0

@@ -4,0 +16,0 @@

9

dist/cjs/use-event-listener.js

@@ -32,5 +32,10 @@ "use strict";

if (!env) return undefined;
env.addEventListener(event, fn, options);
var listener = function listener(event) {
fn(event);
};
env.addEventListener(event, listener, options);
return function () {
env.removeEventListener(event, fn, options);
env.removeEventListener(event, listener, options);
};

@@ -37,0 +42,0 @@ }, [event, env, options, fn]);

@@ -9,2 +9,4 @@ "use strict";

var _useSafeLayoutEffect = require("./use-safe-layout-effect");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

@@ -14,8 +16,11 @@

/**
* Credit: https://github.com/reach/reach-ui/blob/develop/packages/auto-id/src/index.tsx
*/
var handoffComplete = false;
var id = 0;
function genId() {
id += 1;
return id;
}
var genId = function genId() {
return ++id;
};
/**

@@ -30,8 +35,17 @@ * Reack hook to generate unique id

function useId(idProp, prefix) {
var _React$useState = React.useState(function () {
return genId();
}),
uuid = _React$useState[0];
var initialId = idProp || (handoffComplete ? genId() : null);
var id = (idProp != null ? idProp : uuid).toString();
var _React$useState = React.useState(initialId),
uid = _React$useState[0],
setUid = _React$useState[1];
(0, _useSafeLayoutEffect.useSafeLayoutEffect)(function () {
if (uid === null) setUid(genId());
}, []);
React.useEffect(function () {
if (handoffComplete === false) {
handoffComplete = true;
}
}, []);
var id = uid != null ? uid.toString() : undefined;
return prefix ? prefix + "-" + id : id;

@@ -38,0 +52,0 @@ }

@@ -21,5 +21,10 @@ import * as React from "react";

if (!env) return undefined;
env.addEventListener(event, fn, options);
var listener = event => {
fn(event);
};
env.addEventListener(event, listener, options);
return () => {
env.removeEventListener(event, fn, options);
env.removeEventListener(event, listener, options);
};

@@ -26,0 +31,0 @@ }, [event, env, options, fn]);

import * as React from "react";
import { useSafeLayoutEffect } from "./use-safe-layout-effect";
/**
* Credit: https://github.com/reach/reach-ui/blob/develop/packages/auto-id/src/index.tsx
*/
var handoffComplete = false;
var id = 0;
function genId() {
id += 1;
return id;
}
var genId = () => ++id;
/**

@@ -17,4 +20,13 @@ * Reack hook to generate unique id

export function useId(idProp, prefix) {
var [uuid] = React.useState(() => genId());
var id = (idProp != null ? idProp : uuid).toString();
var initialId = idProp || (handoffComplete ? genId() : null);
var [uid, setUid] = React.useState(initialId);
useSafeLayoutEffect(() => {
if (uid === null) setUid(genId());
}, []);
React.useEffect(() => {
if (handoffComplete === false) {
handoffComplete = true;
}
}, []);
var id = uid != null ? uid.toString() : undefined;
return prefix ? prefix + "-" + id : id;

@@ -21,0 +33,0 @@ }

{
"name": "@chakra-ui/hooks",
"version": "1.1.0",
"version": "1.1.1",
"description": "React hooks for Chakra components",

@@ -5,0 +5,0 @@ "keywords": [

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