Skip to content

Commit ebe94f9

Browse files
committed
react 18 fixes except react-table
1 parent 4533792 commit ebe94f9

30 files changed

+305
-377
lines changed

components/BaseCard.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FC } from "react";
1+
import type { Dispatch, ReactNode, SetStateAction } from "react";
22
import { useState } from "react";
33

44
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
@@ -18,10 +18,12 @@ import {
1818
* {@label ActionsParams}
1919
*/
2020
export interface ActionsParams {
21-
setExpanded: (isExpanded: boolean) => void;
21+
[key: string]: unknown;
22+
setExpanded: Dispatch<SetStateAction<boolean>>;
2223
}
2324

2425
export interface BaseCardProps {
26+
children?: ReactNode;
2527
/**
2628
* ReactNode or Component to render in the <CardActions> component. Optional - nothing is
2729
* displayed if not passed.
@@ -30,12 +32,12 @@ export interface BaseCardProps {
3032
*
3133
* {@label actions}
3234
*/
33-
actions?: React.ReactNode | ((actionsParams: ActionsParams) => React.ReactNode);
35+
actions?: ReactNode | ((actionsParams: ActionsParams) => ReactNode);
3436
/**
3537
* ReactNode to be rendered inside the collapsed part of the card. Optional - nothing is
3638
* displayed if not passed.
3739
*/
38-
collapsed?: React.ReactNode;
40+
collapsed?: ReactNode;
3941
/**
4042
* Whether the card is collapsed by default. Optional. Defaults to `true`.
4143
*/
@@ -65,14 +67,14 @@ export interface BaseCardProps {
6567
* * an optional collapsed view that can be enabled by default
6668
* * children are passed into the main area (unexpanded view) of the component
6769
*/
68-
export const BaseCard: FC<BaseCardProps> = ({
70+
export const BaseCard = ({
6971
children,
7072
actions,
7173
header,
7274
collapsed,
7375
keepCollapsedMounted = true,
7476
collapsedByDefault = true,
75-
}) => {
77+
}: BaseCardProps) => {
7678
const [hasExpanded, setHasExpanded] = useState(!collapsedByDefault);
7779
const [expanded, setExpanded] = useState(!collapsedByDefault);
7880

components/PageSection/PageSection.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FC } from "react";
1+
import type { FC, ReactNode } from "react";
22

33
import { Box, Typography } from "@mui/material";
44

@@ -7,6 +7,7 @@ import type { PageSectionLevel } from "./types";
77
import { usePageSectionContext } from "./usePageSectionContext";
88

99
export interface PageSectionProps {
10+
children: ReactNode;
1011
/**
1112
* If provided, overrides the derived level from PageSectionContext. Used for displaying a heading
1213
* element.

components/PageSection/PageSectionProvider.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import type { FC } from "react";
1+
import type { FC, ReactNode } from "react";
22
import { useMemo } from "react";
33

44
import { PageSectionContext } from "./PageSectionContext";
55
import type { PageSectionContextType } from "./types";
66

7+
export interface PageSectionProviderProps extends PageSectionContextType {
8+
children: ReactNode;
9+
}
10+
711
/**
812
* A context provider for `PageSectionContext` context.
913
*/
10-
export const PageSectionProvider: FC<PageSectionContextType> = ({ children, level }) => {
14+
export const PageSectionProvider: FC<PageSectionProviderProps> = ({ children, level }) => {
1115
const contextValue = useMemo<PageSectionContextType>(() => {
1216
return { level };
1317
}, [level]);

components/app/ThemeProviders.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FC } from "react";
1+
import type { FC, ReactNode } from "react";
22
import { useEffect, useState } from "react";
33

44
import { generateThemes } from "@squonk/mui-theme";
@@ -10,10 +10,14 @@ import { useColorScheme } from "../../state/colorScheme";
1010

1111
const { darkTheme, lightTheme } = generateThemes();
1212

13+
export interface ThemeProvidersProps {
14+
children: ReactNode;
15+
}
16+
1317
/**
1418
* Provides the theme for Mui and emotion
1519
*/
16-
export const ThemeProviders: FC = ({ children }) => {
20+
export const ThemeProviders: FC<ThemeProvidersProps> = ({ children }) => {
1721
// Color Scheme
1822
const [scheme] = useColorScheme();
1923
const [theme, setTheme] = useState(lightTheme);

components/auth/RoleRequired.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import type { FC } from "react";
1+
import type { FC, ReactNode } from "react";
22

33
import Error from "next/error";
44

55
import { useKeycloakUser } from "../../hooks/useKeycloakUser";
66

77
export interface RoleRequiredProps {
8+
children?: ReactNode;
89
/**
910
* Roles the user is required to have.
1011
*/

components/finance/ProductCharges.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ export const ProductCharges = ({ productId }: ProductChargesProps) => {
131131
<TableCell>{charge.item_number}</TableCell>
132132
<TableCell>{charge.date}</TableCell>
133133
{/* TODO: assert additional_data to interface from data-manager-client when it's updated */}
134-
<TableCell>{filesize(charge.additional_data?.peak_bytes ?? 0)}</TableCell>
134+
{/* TODO: replace the static type assertion with a proper assertion or find way to get string response only from filesize */}
135+
<TableCell>
136+
{filesize(charge.additional_data?.peak_bytes ?? 0) as string}
137+
</TableCell>
135138
<TableCell>{formatCoins(charge.coins)}</TableCell>
136139
</TableRow>
137140
))

components/modals/ModalWrapper.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { ReactNode } from "react";
2+
13
import CloseRoundedIcon from "@mui/icons-material/CloseRounded";
24
import {
35
Button,
@@ -14,6 +16,7 @@ import { SlideUpTransition } from "../SlideUpTransition";
1416
import type { BaseModalWrapperProps } from "./types";
1517

1618
export interface ModalWrapperProps extends BaseModalWrapperProps {
19+
children: ReactNode;
1720
/**
1821
* Called when the primary action is clicked
1922
*/

components/results/ResultCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import { DateTimeListItem } from "./DateTimeListItem";
1313
import type { StatusIconProps } from "./StatusIcon";
1414
import { StatusIcon } from "./StatusIcon";
1515

16-
export interface ResultCardProps extends BaseCardProps {
16+
export interface ResultCardProps extends Omit<BaseCardProps, "actions"> {
1717
state?: StatusIconProps["state"];
1818
href: LinkProps["href"];
1919
linkTitle: string;
2020
createdDateTime: DateTimeListItemProps["datetimeString"];
2121
collapsedByDefault: boolean;
2222
actions: (
23-
params: ActionsParams & { setSlideIn: Dispatch<SetStateAction<boolean>>; slideIn: boolean },
23+
params: { slideIn: boolean; setSlideIn: Dispatch<SetStateAction<boolean>> } & ActionsParams,
2424
) => ReactNode;
2525
}
2626

components/uploads/Dropzone.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FC } from "react";
1+
import type { FC, ReactNode } from "react";
22
import { useCallback } from "react";
33
import type { DropzoneOptions, FileRejection } from "react-dropzone";
44
import { useDropzone } from "react-dropzone";
@@ -12,6 +12,7 @@ import type { UploadableFile } from "./types";
1212
import { getMimeFromFileName } from "./utils";
1313

1414
export interface DropzoneProps extends DropzoneOptions {
15+
children?: ReactNode;
1516
/**
1617
* The current files a user has dropped
1718
*/

context/MDXComponentProvider.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AnchorHTMLAttributes, DetailedHTMLProps, FC } from "react";
1+
import type { AnchorHTMLAttributes, DetailedHTMLProps, FC, ReactNode } from "react";
22

33
import { MDXProvider } from "@mdx-js/react";
44
import { Link, Typography } from "@mui/material";
@@ -12,7 +12,11 @@ type NextLinkProps = Omit<
1212
> &
1313
LinkProps;
1414

15-
export const MDXComponentProvider: FC = ({ children }) => {
15+
export interface MDXComponentProviderProps {
16+
children: ReactNode;
17+
}
18+
19+
export const MDXComponentProvider: FC<MDXComponentProviderProps> = ({ children }) => {
1620
return (
1721
<MDXProvider
1822
components={{

0 commit comments

Comments
 (0)