@fluentui/react-context-selector
Advanced tools
Comparing version 9.0.0-alpha.16 to 9.0.0-alpha.17
@@ -5,3 +5,18 @@ { | ||
{ | ||
"date": "Fri, 09 Jul 2021 07:30:50 GMT", | ||
"date": "Thu, 15 Jul 2021 07:32:35 GMT", | ||
"tag": "@fluentui/react-context-selector_v9.0.0-alpha.17", | ||
"version": "9.0.0-alpha.17", | ||
"comments": { | ||
"prerelease": [ | ||
{ | ||
"comment": "feat(useHasParentContext): new hook to determine if a context provider exists as parent", | ||
"author": "lingfan.gao@microsoft.com", | ||
"commit": "fce57b22cb51acd0b125421278655258b871c1b5", | ||
"package": "@fluentui/react-context-selector" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Fri, 09 Jul 2021 07:39:31 GMT", | ||
"tag": "@fluentui/react-context-selector_v9.0.0-alpha.16", | ||
@@ -8,0 +23,0 @@ "version": "9.0.0-alpha.16", |
# Change Log - @fluentui/react-context-selector | ||
This log was last generated on Fri, 09 Jul 2021 07:30:50 GMT and should not be manually modified. | ||
This log was last generated on Thu, 15 Jul 2021 07:32:35 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## [9.0.0-alpha.17](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.0.0-alpha.17) | ||
Thu, 15 Jul 2021 07:32:35 GMT | ||
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-alpha.16..@fluentui/react-context-selector_v9.0.0-alpha.17) | ||
### Changes | ||
- feat(useHasParentContext): new hook to determine if a context provider exists as parent ([PR #18812](https://github.com/microsoft/fluentui/pull/18812) by lingfan.gao@microsoft.com) | ||
## [9.0.0-alpha.16](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.0.0-alpha.16) | ||
Fri, 09 Jul 2021 07:30:50 GMT | ||
Fri, 09 Jul 2021 07:39:31 GMT | ||
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-alpha.15..@fluentui/react-context-selector_v9.0.0-alpha.16) | ||
@@ -11,0 +20,0 @@ |
@@ -35,2 +35,11 @@ import * as React_2 from 'react'; | ||
/** | ||
* Utility hook for contexts created by react-context-selector to determine if a parent context exists | ||
* WARNING: This hook will not work for native React contexts | ||
* | ||
* @param context - context created by react-context-selector | ||
* @returns whether the hook is wrapped by a parent context | ||
*/ | ||
export declare function useHasParentContext<Value>(context: Context<Value>): boolean; | ||
export { } |
@@ -39,5 +39,8 @@ ## API Report File for "@fluentui/react-context-selector" | ||
// @public | ||
export function useHasParentContext<Value>(context: Context<Value>): boolean; | ||
// (No @packageDocumentation comment for this package) | ||
``` |
export { createContext } from './createContext'; | ||
export { useContextSelector } from './useContextSelector'; | ||
export { useHasParentContext } from './useHasParentContext'; | ||
export * from './types'; |
@@ -1,9 +0,10 @@ | ||
define(["require", "exports", "tslib", "./createContext", "./useContextSelector", "./types"], function (require, exports, tslib_1, createContext_1, useContextSelector_1, types_1) { | ||
define(["require", "exports", "tslib", "./createContext", "./useContextSelector", "./useHasParentContext", "./types"], function (require, exports, tslib_1, createContext_1, useContextSelector_1, useHasParentContext_1, types_1) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useContextSelector = exports.createContext = void 0; | ||
exports.useHasParentContext = exports.useContextSelector = exports.createContext = void 0; | ||
Object.defineProperty(exports, "createContext", { enumerable: true, get: function () { return createContext_1.createContext; } }); | ||
Object.defineProperty(exports, "useContextSelector", { enumerable: true, get: function () { return useContextSelector_1.useContextSelector; } }); | ||
Object.defineProperty(exports, "useHasParentContext", { enumerable: true, get: function () { return useHasParentContext_1.useHasParentContext; } }); | ||
tslib_1.__exportStar(types_1, exports); | ||
}); | ||
//# sourceMappingURL=index.js.map |
export { createContext } from './createContext'; | ||
export { useContextSelector } from './useContextSelector'; | ||
export { useHasParentContext } from './useHasParentContext'; | ||
export * from './types'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useContextSelector = exports.createContext = void 0; | ||
exports.useHasParentContext = exports.useContextSelector = exports.createContext = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -9,3 +9,5 @@ var createContext_1 = require("./createContext"); | ||
Object.defineProperty(exports, "useContextSelector", { enumerable: true, get: function () { return useContextSelector_1.useContextSelector; } }); | ||
var useHasParentContext_1 = require("./useHasParentContext"); | ||
Object.defineProperty(exports, "useHasParentContext", { enumerable: true, get: function () { return useHasParentContext_1.useHasParentContext; } }); | ||
tslib_1.__exportStar(require("./types"), exports); | ||
//# sourceMappingURL=index.js.map |
export { createContext } from './createContext'; | ||
export { useContextSelector } from './useContextSelector'; | ||
export { useHasParentContext } from './useHasParentContext'; | ||
export * from './types'; |
export { createContext } from './createContext'; | ||
export { useContextSelector } from './useContextSelector'; | ||
export { useHasParentContext } from './useHasParentContext'; | ||
export * from './types'; | ||
//# sourceMappingURL=index.js.map |
@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard. | ||
"packageName": "@microsoft/api-extractor", | ||
"packageVersion": "7.13.0" | ||
"packageVersion": "7.18.1" | ||
} | ||
] | ||
} |
{ | ||
"name": "@fluentui/react-context-selector", | ||
"version": "9.0.0-alpha.16", | ||
"version": "9.0.0-alpha.17", | ||
"description": "React useContextSelector hook in userland", | ||
@@ -37,3 +37,3 @@ "main": "lib-commonjs/index.js", | ||
"dependencies": { | ||
"@fluentui/react-utilities": "^9.0.0-alpha.32", | ||
"@fluentui/react-utilities": "^9.0.0-alpha.33", | ||
"scheduler": "^0.20.1", | ||
@@ -40,0 +40,0 @@ "tslib": "^2.1.0" |
@@ -28,2 +28,4 @@ # `@fluentui/react-context-selector` | ||
### Getting started | ||
```tsx | ||
@@ -90,2 +92,20 @@ import * as React from 'react'; | ||
### useHasParentContext | ||
This helper hook will allow you to know if a component is wrapped by a context selector provider | ||
```tsx | ||
const Foo = () => { | ||
// An easy way to test if a context provider is wrapped around this component | ||
// since it's more complicated to compare with a default context value | ||
const isWrappedWithContext = useHasParentContext(CounterContext); | ||
if (isWrappedWithContext) { | ||
return <div>I am inside context selector provider</div>; | ||
} else { | ||
return <div>I can only use default context value</div>; | ||
} | ||
}; | ||
``` | ||
## Technical memo | ||
@@ -92,0 +112,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
855071
189
3380
125
1
6