Socket
Socket
Sign inDemoInstall

@fluentui/react-context-selector

Package Overview
Dependencies
2
Maintainers
12
Versions
792
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.0-nightly-20240613-0406.1 to 0.0.0-nightly-20240614-0405.1

10

CHANGELOG.md
# Change Log - @fluentui/react-context-selector
This log was last generated on Thu, 13 Jun 2024 04:37:57 GMT and should not be manually modified.
This log was last generated on Fri, 14 Jun 2024 04:38:02 GMT and should not be manually modified.
<!-- Start content -->
## [0.0.0-nightly-20240613-0406.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v0.0.0-nightly-20240613-0406.1)
## [0.0.0-nightly-20240614-0405.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v0.0.0-nightly-20240614-0405.1)
Thu, 13 Jun 2024 04:37:57 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.1.61..@fluentui/react-context-selector_v0.0.0-nightly-20240613-0406.1)
Fri, 14 Jun 2024 04:38:02 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.1.61..@fluentui/react-context-selector_v0.0.0-nightly-20240614-0405.1)

@@ -15,3 +15,3 @@ ### Changes

- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
- Bump @fluentui/react-utilities to v0.0.0-nightly-20240613-0406.1 ([commit](https://github.com/microsoft/fluentui/commit/ddd7d1af4015630e7fa74be52b3bae7fc38a2856) by beachball)
- Bump @fluentui/react-utilities to v0.0.0-nightly-20240614-0405.1 ([commit](https://github.com/microsoft/fluentui/commit/7b8bdab954639a4eb1711201b04c57f781019f71) by beachball)

@@ -18,0 +18,0 @@ ## [9.1.61](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.1.61)

@@ -18,44 +18,47 @@ "use strict";

const selected = selector(value);
const [state, dispatch] = _react.useReducer((prevState, payload)=>{
if (!payload) {
// early bail out when is dispatched during render
return [
value,
selected
];
}
if (payload[0] <= version) {
if (objectIs(prevState[1], selected)) {
return prevState; // bail out
const [state, setState] = _react.useState([
value,
selected
]);
const dispatch = (payload)=>{
setState((prevState)=>{
if (!payload) {
// early bail out when is dispatched during render
return [
value,
selected
];
}
return [
value,
selected
];
}
try {
if (objectIs(prevState[0], payload[1])) {
return prevState; // do not update
if (payload[0] <= version) {
if (Object.is(prevState[1], selected)) {
return prevState; // bail out
}
return [
value,
selected
];
}
const nextSelected = selector(payload[1]);
if (objectIs(prevState[1], nextSelected)) {
return prevState; // do not update
try {
if (Object.is(prevState[0], payload[1])) {
return prevState; // do not update
}
const nextSelected = selector(payload[1]);
if (Object.is(prevState[1], nextSelected)) {
return prevState; // do not update
}
return [
payload[1],
nextSelected
];
} catch (e) {
// ignored (stale props or some other reason)
}
// explicitly spread to enforce typing
return [
payload[1],
nextSelected
];
} catch (e) {
// ignored (stale props or some other reason)
}
// explicitly spread to enforce typing
return [
prevState[0],
prevState[1]
]; // schedule update
}, [
value,
selected
]);
if (!objectIs(state[1], selected)) {
prevState[0],
prevState[1]
]; // schedule update
});
};
if (!Object.is(state[1], selected)) {
// schedule re-render

@@ -65,9 +68,11 @@ // this is safe because it's self contained

}
const stableDispatch = (0, _reactutilities.useEventCallback)(dispatch);
(0, _reactutilities.useIsomorphicLayoutEffect)(()=>{
listeners.push(dispatch);
listeners.push(stableDispatch);
return ()=>{
const index = listeners.indexOf(dispatch);
const index = listeners.indexOf(stableDispatch);
listeners.splice(index, 1);
};
}, [
stableDispatch,
listeners

@@ -77,12 +82,1 @@ ]);

};
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
function is(x, y) {
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const objectIs = // @ts-ignore fallback to native if it exists (not in IE11)
typeof Object.is === 'function' ? Object.is : is;

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

import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
import { useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
import * as React from 'react';

@@ -12,44 +12,47 @@ /**

const selected = selector(value);
const [state, dispatch] = React.useReducer((prevState, payload)=>{
if (!payload) {
// early bail out when is dispatched during render
return [
value,
selected
];
}
if (payload[0] <= version) {
if (objectIs(prevState[1], selected)) {
return prevState; // bail out
const [state, setState] = React.useState([
value,
selected
]);
const dispatch = (payload)=>{
setState((prevState)=>{
if (!payload) {
// early bail out when is dispatched during render
return [
value,
selected
];
}
return [
value,
selected
];
}
try {
if (objectIs(prevState[0], payload[1])) {
return prevState; // do not update
if (payload[0] <= version) {
if (Object.is(prevState[1], selected)) {
return prevState; // bail out
}
return [
value,
selected
];
}
const nextSelected = selector(payload[1]);
if (objectIs(prevState[1], nextSelected)) {
return prevState; // do not update
try {
if (Object.is(prevState[0], payload[1])) {
return prevState; // do not update
}
const nextSelected = selector(payload[1]);
if (Object.is(prevState[1], nextSelected)) {
return prevState; // do not update
}
return [
payload[1],
nextSelected
];
} catch (e) {
// ignored (stale props or some other reason)
}
// explicitly spread to enforce typing
return [
payload[1],
nextSelected
];
} catch (e) {
// ignored (stale props or some other reason)
}
// explicitly spread to enforce typing
return [
prevState[0],
prevState[1]
]; // schedule update
}, [
value,
selected
]);
if (!objectIs(state[1], selected)) {
prevState[0],
prevState[1]
]; // schedule update
});
};
if (!Object.is(state[1], selected)) {
// schedule re-render

@@ -59,9 +62,11 @@ // this is safe because it's self contained

}
const stableDispatch = useEventCallback(dispatch);
useIsomorphicLayoutEffect(()=>{
listeners.push(dispatch);
listeners.push(stableDispatch);
return ()=>{
const index = listeners.indexOf(dispatch);
const index = listeners.indexOf(stableDispatch);
listeners.splice(index, 1);
};
}, [
stableDispatch,
listeners

@@ -71,13 +76,1 @@ ]);

};
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
function is(x, y) {
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const objectIs = // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore fallback to native if it exists (not in IE11)
typeof Object.is === 'function' ? Object.is : is;
{
"name": "@fluentui/react-context-selector",
"version": "0.0.0-nightly-20240613-0406.1",
"version": "0.0.0-nightly-20240614-0405.1",
"description": "React useContextSelector hook in userland",

@@ -31,3 +31,3 @@ "main": "lib-commonjs/index.js",

"dependencies": {
"@fluentui/react-utilities": "0.0.0-nightly-20240613-0406.1",
"@fluentui/react-utilities": "0.0.0-nightly-20240614-0405.1",
"@swc/helpers": "^0.5.1"

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc