React 18 and Vite (#4510)

This commit is contained in:
Matthew Penner 2022-11-25 13:25:03 -07:00 committed by GitHub
parent 1bb1b13f6d
commit 21613fa602
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
244 changed files with 4547 additions and 8933 deletions

View file

@ -1,24 +1,25 @@
import React, { memo } from 'react';
import { usePermissions } from '@/plugins/usePermissions';
import type { ReactNode } from 'react';
import { memo } from 'react';
import isEqual from 'react-fast-compare';
import { usePermissions } from '@/plugins/usePermissions';
interface Props {
action: string | string[];
matchAny?: boolean;
renderOnError?: React.ReactNode | null;
children: React.ReactNode;
renderOnError?: ReactNode | null;
children: ReactNode;
}
const Can = ({ action, matchAny = false, renderOnError, children }: Props) => {
function Can({ action, matchAny = false, renderOnError, children }: Props) {
const can = usePermissions(action);
return (
<>
{(matchAny && can.filter((p) => p).length > 0) || (!matchAny && can.every((p) => p))
? children
: renderOnError}
{(matchAny && can.filter(p => p).length > 0) || (!matchAny && can.every(p => p)) ? children : renderOnError}
</>
);
};
}
export default memo(Can, isEqual);
const MemoizedCan = memo(Can, isEqual);
export default MemoizedCan;