Skip to content

Commit 43263c4

Browse files
author
Becca Bailey
authored
Merge pull request #2325 from FormidableLabs/bug/use-context-selector
Remove dependency on use-context-selector
2 parents 13339bd + e585590 commit 43263c4

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
"ts-jest": "^28.0.3",
121121
"ts-loader": "^9.3.0",
122122
"typescript": "^4.7.3",
123-
"use-context-selector": "^1.4.1",
124123
"webpack": "^5.72.1",
125124
"webpack-cli": "^4.9.2",
126125
"webpack-dev-server": "^4.9.0",

packages/victory-core/src/victory-state/victory-provider.tsx

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from "react";
2-
import { createContext, useContextSelector } from "use-context-selector";
2+
import { createContext, useContext } from "react";
33
import { D3ScaleFn, DomainTuple, ForAxes } from "../types/prop-types";
44
import { FormattedDatum, getData } from "./helpers/get-data";
55
import { getDomain } from "./helpers/get-domain";
@@ -81,17 +81,12 @@ export function VictoryProvider({
8181
);
8282
}
8383

84-
type ContextValue = ContextType | null;
85-
8684
export function useVictoryContext<T>(selector: (value: ContextType) => T): T {
87-
return useContextSelector<ContextValue, T>(VictoryContext, (context) => {
88-
if (!context) {
89-
throw new Error(
90-
"useVictoryContext must be used within a VictoryProvider",
91-
);
92-
}
93-
return selector(context);
94-
});
85+
const context = useContext(VictoryContext);
86+
if (!context) {
87+
throw new Error("useVictoryContext must be used within a VictoryProvider");
88+
}
89+
return selector(context);
9590
}
9691

9792
export function useScale() {

yarn.lock

-5
Original file line numberDiff line numberDiff line change
@@ -17593,11 +17593,6 @@ url@^0.11.0:
1759317593
punycode "1.3.2"
1759417594
querystring "0.2.0"
1759517595

17596-
use-context-selector@^1.4.1:
17597-
version "1.4.1"
17598-
resolved "https://registry.yarnpkg.com/use-context-selector/-/use-context-selector-1.4.1.tgz#eb96279965846b72915d7f899b8e6ef1d768b0ae"
17599-
integrity sha512-Io2ArvcRO+6MWIhkdfMFt+WKQX+Vb++W8DS2l03z/Vw/rz3BclKpM0ynr4LYGyU85Eke+Yx5oIhTY++QR0ZDoA==
17600-
1760117596
use-subscription@^1.0.0:
1760217597
version "1.7.0"
1760317598
resolved "https://registry.yarnpkg.com/use-subscription/-/use-subscription-1.7.0.tgz#c7505263315deac9fd2581cdf4ab1e3ff2585d0f"

0 commit comments

Comments
 (0)