Skip to content

Commit

Permalink
Just add the dependency...
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Haines <haines@cerbos.dev>
  • Loading branch information
haines committed Mar 22, 2024
1 parent adf43f1 commit 3040849
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 105 deletions.
5 changes: 3 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@
"React"
],
"peerDependencies": {
"react": ">=16.8.0"
"react": ">=16.13.0"
},
"dependencies": {
"@cerbos/core": "^0.16.0"
"@cerbos/core": "^0.16.0",
"use-deep-compare-effect": "^1.8.1"
},
"devDependencies": {
"@types/react": "18.2.67",
Expand Down
7 changes: 3 additions & 4 deletions packages/react/src/cerbos-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import type {
} from "@cerbos/core";
import type { ReactElement, ReactNode } from "react";
import { createContext, useMemo } from "react";

import { useDeepEqualMemo } from "./use-deep-equal-memo";
import { useDeepCompareMemoize } from "use-deep-compare-effect";

export const CerbosContext = createContext<ClientWithPrincipal | undefined>(
undefined,
Expand Down Expand Up @@ -65,8 +64,8 @@ export function CerbosProvider({
principal,
auxData,
}: CerbosProviderProps): ReactElement {
const principalMemo = useDeepEqualMemo(principal);
const auxDataMemo = useDeepEqualMemo(auxData);
const principalMemo = useDeepCompareMemoize(principal);
const auxDataMemo = useDeepCompareMemoize(auxData);

const value = useMemo(
() => client.withPrincipal(principalMemo, auxDataMemo),
Expand Down
55 changes: 0 additions & 55 deletions packages/react/src/deep-equal.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/react/src/use-cerbos-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import type {
RequestOptions,
} from "@cerbos/core";
import { useCallback, useEffect, useState } from "react";
import { useDeepCompareMemoize } from "use-deep-compare-effect";

import { useCerbos } from "./use-cerbos";
import { useDeepEqualMemo } from "./use-deep-equal-memo";

/**
* @public
Expand All @@ -35,7 +35,7 @@ function useCerbosRequest<Method extends Methods>(
const [error, setError] = useState<Error>();

const client = useCerbos();
const paramsMemo = useDeepEqualMemo(params);
const paramsMemo = useDeepCompareMemoize(params);

const load = useCallback<() => Promise<Result<Method>>>(
// @ts-expect-error -- https://github.com/microsoft/TypeScript/issues/30581
Expand Down
40 changes: 0 additions & 40 deletions packages/react/src/use-deep-equal-memo.ts

This file was deleted.

21 changes: 19 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3040849

Please sign in to comment.