Socket
Socket
Sign inDemoInstall

@react-aria/utils

Package Overview
Dependencies
Maintainers
1
Versions
753
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-aria/utils - npm Package Compare versions

Comparing version 3.0.0-nightly.710 to 3.0.0-nightly.715

29

dist/main.js

@@ -12,5 +12,5 @@ var _clsx = $parcel$interopDefault(require("clsx"));

var {
useState,
useEffect,
useRef,
useEffect
useState
} = _react2;

@@ -34,5 +34,28 @@

function useId(defaultId) {
let isRendering = useRef(true);
isRendering.current = true;
let [value, setValue] = useState(defaultId);
let nextId = useRef(null); // don't memo this, we want it new each render so that the Effects always run
let updateValue = val => {
if (!isRendering.current) {
setValue(val);
} else {
nextId.current = val;
}
};
useLayoutEffect(() => {
isRendering.current = false;
}, [updateValue]);
useEffect(() => {
let newId = nextId.current;
if (newId) {
setValue(newId);
nextId.current = null;
}
}, [setValue, updateValue]);
let res = useSSRSafeId(value);
$f09fcd7f5f367fc80aacfeac62ed2$var$map.set(res, setValue);
$f09fcd7f5f367fc80aacfeac62ed2$var$map.set(res, updateValue);
return res;

@@ -39,0 +62,0 @@ }

import _clsx from "clsx";
import { useSSRSafeId } from "@react-aria/ssr";
import _react, { useState, useRef, useEffect } from "react";
import _react, { useEffect, useRef, useState } from "react";
// During SSR, React emits a warning when calling useLayoutEffect.

@@ -15,5 +15,28 @@ // Since neither useLayoutEffect nor useEffect run on the server,

export function useId(defaultId) {
let isRendering = useRef(true);
isRendering.current = true;
let [value, setValue] = useState(defaultId);
let nextId = useRef(null); // don't memo this, we want it new each render so that the Effects always run
let updateValue = val => {
if (!isRendering.current) {
setValue(val);
} else {
nextId.current = val;
}
};
useLayoutEffect(() => {
isRendering.current = false;
}, [updateValue]);
useEffect(() => {
let newId = nextId.current;
if (newId) {
setValue(newId);
nextId.current = null;
}
}, [setValue, updateValue]);
let res = useSSRSafeId(value);
$f8b5fdd96fb429d7102983f777c41307$var$map.set(res, setValue);
$f8b5fdd96fb429d7102983f777c41307$var$map.set(res, updateValue);
return res;

@@ -20,0 +43,0 @@ }

10

package.json
{
"name": "@react-aria/utils",
"version": "3.0.0-nightly.710+da1f0a8a",
"version": "3.0.0-nightly.715+bd9852ce",
"description": "Spectrum UI components in React",

@@ -21,8 +21,8 @@ "license": "Apache-2.0",

"@babel/runtime": "^7.6.2",
"@react-aria/ssr": "3.0.1-nightly.2388+da1f0a8a",
"@react-types/shared": "3.0.0-nightly.710+da1f0a8a",
"@react-aria/ssr": "3.0.1-nightly.2393+bd9852ce",
"@react-types/shared": "3.0.0-nightly.715+bd9852ce",
"clsx": "^1.1.1"
},
"peerDependencies": {
"react": "^16.8.0"
"react": "^16.8.0 || ^17.0.0-rc.1"
},

@@ -32,3 +32,3 @@ "publishConfig": {

},
"gitHead": "da1f0a8a149db773b61c8ae61a99ec0139db7b29"
"gitHead": "bd9852ce71c11a970a135668373e16cf8962dc3c"
}

@@ -13,5 +13,5 @@ /*

import {useEffect, useRef, useState} from 'react';
import {useLayoutEffect} from './useLayoutEffect';
import {useSSRSafeId} from '@react-aria/ssr';
import {useState} from 'react';

@@ -25,5 +25,29 @@ let map: Map<string, (v: string) => void> = new Map();

export function useId(defaultId?: string): string {
let isRendering = useRef(true);
isRendering.current = true;
let [value, setValue] = useState(defaultId);
let nextId = useRef(null);
// don't memo this, we want it new each render so that the Effects always run
let updateValue = (val) => {
if (!isRendering.current) {
setValue(val);
} else {
nextId.current = val;
}
};
useLayoutEffect(() => {
isRendering.current = false;
}, [updateValue]);
useEffect(() => {
let newId = nextId.current;
if (newId) {
setValue(newId);
nextId.current = null;
}
}, [setValue, updateValue]);
let res = useSSRSafeId(value);
map.set(res, setValue);
map.set(res, updateValue);
return res;

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

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