From 931302cbec36b998761b2b3d2d2b451f8d5b24f7 Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Sat, 9 Apr 2022 23:16:06 +0200 Subject: [PATCH] Fix react 18 changes Signed-off-by: Tilman Vatteroth --- src/components/application-loader/application-loader.tsx | 3 ++- src/components/common/async-loading-boundary.tsx | 3 ++- src/components/common/modals/common-modal.tsx | 3 ++- src/components/common/modals/deletion-modal.tsx | 3 ++- src/components/common/pagination/pager.tsx | 3 ++- src/components/common/routing/not-found-error-screen.tsx | 3 ++- src/components/common/show-if/show-if.tsx | 3 ++- .../document-info/document-info-line-word-count.tsx | 3 ++- .../document-bar/document-info/document-info-line.tsx | 3 ++- .../editor-to-renderer-communicator-context-provider.tsx | 3 ++- .../renderer-to-editor-communicator-context-provider.tsx | 3 ++- .../delete-note-sidebar-entry.tsx | 3 ++- .../sidebar/sidebar-button/sidebar-button.tsx | 5 +++-- .../editor-page/sidebar/sidebar-menu/sidebar-menu.tsx | 3 ++- src/components/error-boundary/error-boundary.tsx | 4 ++-- .../history-toolbar-state-context-provider.tsx | 3 ++- src/components/landing-layout/landing-layout.tsx | 3 ++- .../navigation/header-bar/header-nav-link.tsx | 3 ++- .../auth/social-link-button/social-link-button.tsx | 9 ++++++++- .../replace-components/click-shield/click-shield.tsx | 3 ++- 20 files changed, 47 insertions(+), 22 deletions(-) diff --git a/src/components/application-loader/application-loader.tsx b/src/components/application-loader/application-loader.tsx index 687504f2b..9f0e21641 100644 --- a/src/components/application-loader/application-loader.tsx +++ b/src/components/application-loader/application-loader.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React, { Suspense } from 'react' import { useBackendBaseUrl } from '../../hooks/common/use-backend-base-url' import { createSetUpTaskList } from './initializers' @@ -15,7 +16,7 @@ import { ApplicationLoaderError } from './application-loader-error' const log = new Logger('ApplicationLoader') -export const ApplicationLoader: React.FC = ({ children }) => { +export const ApplicationLoader: React.FC> = ({ children }) => { const backendBaseUrl = useBackendBaseUrl() const customizeAssetsUrl = useCustomizeAssetsUrl() diff --git a/src/components/common/async-loading-boundary.tsx b/src/components/common/async-loading-boundary.tsx index f31fb62a8..e12782a47 100644 --- a/src/components/common/async-loading-boundary.tsx +++ b/src/components/common/async-loading-boundary.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React, { Fragment } from 'react' import { Trans, useTranslation } from 'react-i18next' import { WaitSpinner } from './wait-spinner/wait-spinner' @@ -24,7 +25,7 @@ export interface AsyncLoadingBoundaryProps { * @param componentName The name of the component that is currently loading. It will be shown in the error message. * @param children The child {@link ReactElement elements} that are only shown if the component isn't in loading or error state */ -export const AsyncLoadingBoundary: React.FC = ({ +export const AsyncLoadingBoundary: React.FC> = ({ loading, error, componentName, diff --git a/src/components/common/modals/common-modal.tsx b/src/components/common/modals/common-modal.tsx index bacd0559d..d7a2e5025 100644 --- a/src/components/common/modals/common-modal.tsx +++ b/src/components/common/modals/common-modal.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React, { useMemo } from 'react' import { Modal } from 'react-bootstrap' import { Trans, useTranslation } from 'react-i18next' @@ -29,7 +30,7 @@ export interface ModalContentProps { export type CommonModalProps = PropsWithDataCypressId & ModalVisibilityProps & ModalContentProps -export const CommonModal: React.FC = ({ +export const CommonModal: React.FC> = ({ show, onHide, title, diff --git a/src/components/common/modals/deletion-modal.tsx b/src/components/common/modals/deletion-modal.tsx index 94e0ee4a6..ef559b7d0 100644 --- a/src/components/common/modals/deletion-modal.tsx +++ b/src/components/common/modals/deletion-modal.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React from 'react' import { Button, Modal } from 'react-bootstrap' import { Trans, useTranslation } from 'react-i18next' @@ -16,7 +17,7 @@ export interface DeletionModalProps extends CommonModalProps { deletionButtonI18nKey: string } -export const DeletionModal: React.FC = ({ +export const DeletionModal: React.FC> = ({ show, onHide, title, diff --git a/src/components/common/pagination/pager.tsx b/src/components/common/pagination/pager.tsx index 1db8c88b9..6e1d00db7 100644 --- a/src/components/common/pagination/pager.tsx +++ b/src/components/common/pagination/pager.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React, { Fragment, useEffect } from 'react' export interface PagerPageProps { @@ -12,7 +13,7 @@ export interface PagerPageProps { onLastPageIndexChange: (lastPageIndex: number) => void } -export const Pager: React.FC = ({ +export const Pager: React.FC> = ({ children, numberOfElementsPerPage, pageIndex, diff --git a/src/components/common/routing/not-found-error-screen.tsx b/src/components/common/routing/not-found-error-screen.tsx index bc2dbf04e..04353bd31 100644 --- a/src/components/common/routing/not-found-error-screen.tsx +++ b/src/components/common/routing/not-found-error-screen.tsx @@ -4,10 +4,11 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React from 'react' import { LandingLayout } from '../../landing-layout/landing-layout' -export const NotFoundErrorScreen: React.FC = () => { +export const NotFoundErrorScreen: React.FC> = () => { return (
diff --git a/src/components/common/show-if/show-if.tsx b/src/components/common/show-if/show-if.tsx index cfbf6dc47..a0d12f972 100644 --- a/src/components/common/show-if/show-if.tsx +++ b/src/components/common/show-if/show-if.tsx @@ -4,12 +4,13 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React, { Fragment } from 'react' export interface ShowIfProps { condition: boolean } -export const ShowIf: React.FC = ({ children, condition }) => { +export const ShowIf: React.FC> = ({ children, condition }) => { return condition ? {children} : null } diff --git a/src/components/editor-page/document-bar/document-info/document-info-line-word-count.tsx b/src/components/editor-page/document-bar/document-info/document-info-line-word-count.tsx index 381f03458..c85020607 100644 --- a/src/components/editor-page/document-bar/document-info/document-info-line-word-count.tsx +++ b/src/components/editor-page/document-bar/document-info/document-info-line-word-count.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React, { useCallback, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' import { ShowIf } from '../../../common/show-if/show-if' @@ -20,7 +21,7 @@ import { cypressId } from '../../../../utils/cypress-attribute' * Creates a new info line for the document information dialog that holds the * word count of the note, based on counting in the rendered output. */ -export const DocumentInfoLineWordCount: React.FC = () => { +export const DocumentInfoLineWordCount: React.FC> = () => { useTranslation() const editorToRendererCommunicator = useEditorToRendererCommunicator() const [wordCount, setWordCount] = useState(null) diff --git a/src/components/editor-page/document-bar/document-info/document-info-line.tsx b/src/components/editor-page/document-bar/document-info/document-info-line.tsx index d9ed863e5..9bb6b4e0b 100644 --- a/src/components/editor-page/document-bar/document-info/document-info-line.tsx +++ b/src/components/editor-page/document-bar/document-info/document-info-line.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React from 'react' import { ForkAwesomeIcon } from '../../../common/fork-awesome/fork-awesome-icon' import type { IconName } from '../../../common/fork-awesome/types' @@ -13,7 +14,7 @@ export interface DocumentInfoLineProps { size?: '2x' | '3x' | '4x' | '5x' | undefined } -export const DocumentInfoLine: React.FC = ({ icon, size, children }) => { +export const DocumentInfoLine: React.FC> = ({ icon, size, children }) => { return ( diff --git a/src/components/editor-page/render-context/editor-to-renderer-communicator-context-provider.tsx b/src/components/editor-page/render-context/editor-to-renderer-communicator-context-provider.tsx index 85f2c7495..683ffc600 100644 --- a/src/components/editor-page/render-context/editor-to-renderer-communicator-context-provider.tsx +++ b/src/components/editor-page/render-context/editor-to-renderer-communicator-context-provider.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React, { createContext, useContext, useEffect, useMemo } from 'react' import { EditorToRendererCommunicator } from '../../render-page/window-post-message-communicator/editor-to-renderer-communicator' @@ -26,7 +27,7 @@ export const useEditorToRendererCommunicator: () => EditorToRendererCommunicator /** * Provides a {@link EditorToRendererCommunicator editor to renderer communicator} for the child components via Context. */ -export const EditorToRendererCommunicatorContextProvider: React.FC = ({ children }) => { +export const EditorToRendererCommunicatorContextProvider: React.FC> = ({ children }) => { const communicator = useMemo(() => new EditorToRendererCommunicator(), []) useEffect(() => { diff --git a/src/components/editor-page/render-context/renderer-to-editor-communicator-context-provider.tsx b/src/components/editor-page/render-context/renderer-to-editor-communicator-context-provider.tsx index 636394ad9..f1c6c9903 100644 --- a/src/components/editor-page/render-context/renderer-to-editor-communicator-context-provider.tsx +++ b/src/components/editor-page/render-context/renderer-to-editor-communicator-context-provider.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React, { createContext, useContext, useEffect, useMemo } from 'react' import { RendererToEditorCommunicator } from '../../render-page/window-post-message-communicator/renderer-to-editor-communicator' import { CommunicationMessageType } from '../../render-page/window-post-message-communicator/rendering-message' @@ -25,7 +26,7 @@ export const useRendererToEditorCommunicator: () => RendererToEditorCommunicator return communicatorFromContext } -export const RendererToEditorCommunicatorContextProvider: React.FC = ({ children }) => { +export const RendererToEditorCommunicatorContextProvider: React.FC> = ({ children }) => { const editorOrigin = useOriginFromConfig(ORIGIN_TYPE.EDITOR) const communicator = useMemo(() => new RendererToEditorCommunicator(), []) diff --git a/src/components/editor-page/sidebar/delete-note-sidebar-entry/delete-note-sidebar-entry.tsx b/src/components/editor-page/sidebar/delete-note-sidebar-entry/delete-note-sidebar-entry.tsx index 97c44a068..24c45402e 100644 --- a/src/components/editor-page/sidebar/delete-note-sidebar-entry/delete-note-sidebar-entry.tsx +++ b/src/components/editor-page/sidebar/delete-note-sidebar-entry/delete-note-sidebar-entry.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React, { Fragment, useCallback, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' import { SidebarButton } from '../sidebar-button/sidebar-button' @@ -21,7 +22,7 @@ import { ShowIf } from '../../../common/show-if/show-if' * @param hide {@code true} if the entry shouldn't be visible * @param className Additional css class names for the sidebar entry */ -export const DeleteNoteSidebarEntry: React.FC = ({ hide, className }) => { +export const DeleteNoteSidebarEntry: React.FC> = ({ hide, className }) => { useTranslation() const [showDialog, setShowDialog] = useState(false) const noteId = useApplicationState((state) => state.noteDetails.id) diff --git a/src/components/editor-page/sidebar/sidebar-button/sidebar-button.tsx b/src/components/editor-page/sidebar/sidebar-button/sidebar-button.tsx index e272160ec..41a992d01 100644 --- a/src/components/editor-page/sidebar/sidebar-button/sidebar-button.tsx +++ b/src/components/editor-page/sidebar/sidebar-button/sidebar-button.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React, { useMemo } from 'react' import { ForkAwesomeIcon } from '../../../common/fork-awesome/fork-awesome-icon' import type { IconName } from '../../../common/fork-awesome/types' @@ -19,14 +20,14 @@ export interface SidebarButton extends SidebarEntryProps { * A button that should be rendered in the sidebar. * * @param children The react elements in the button - * @param icon The icon at the left side of the button + * @param icon The icon on the left side of the button * @param className Additional css class names * @param buttonRef A reference to the button * @param hide Should be {@code true} if the button should be invisible * @param variant An alternative theme for the button * @param props Other button props */ -export const SidebarButton: React.FC = ({ +export const SidebarButton: React.FC> = ({ children, icon, className, diff --git a/src/components/editor-page/sidebar/sidebar-menu/sidebar-menu.tsx b/src/components/editor-page/sidebar/sidebar-menu/sidebar-menu.tsx index fbbf3e9d5..00a730346 100644 --- a/src/components/editor-page/sidebar/sidebar-menu/sidebar-menu.tsx +++ b/src/components/editor-page/sidebar/sidebar-menu/sidebar-menu.tsx @@ -4,11 +4,12 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React from 'react' import type { SidebarMenuProps } from '../types' import styles from './sidebar-menu.module.scss' -export const SidebarMenu: React.FC = ({ children, expand }) => { +export const SidebarMenu: React.FC> = ({ children, expand }) => { return (
{children}
diff --git a/src/components/error-boundary/error-boundary.tsx b/src/components/error-boundary/error-boundary.tsx index 9b8542770..d82946c9f 100644 --- a/src/components/error-boundary/error-boundary.tsx +++ b/src/components/error-boundary/error-boundary.tsx @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import type { ErrorInfo, ReactNode } from 'react' +import type { ErrorInfo, PropsWithChildren, ReactNode } from 'react' import React, { Component } from 'react' import { Button, Container } from 'react-bootstrap' import links from '../../links.json' @@ -15,7 +15,7 @@ import { Logger } from '../../utils/logger' const log = new Logger('ErrorBoundary') -export class ErrorBoundary extends Component { +export class ErrorBoundary extends Component> { state: { hasError: boolean } diff --git a/src/components/history-page/history-toolbar/toolbar-context/history-toolbar-state-context-provider.tsx b/src/components/history-page/history-toolbar/toolbar-context/history-toolbar-state-context-provider.tsx index a2ff9b7ca..d067f4d19 100644 --- a/src/components/history-page/history-toolbar/toolbar-context/history-toolbar-state-context-provider.tsx +++ b/src/components/history-page/history-toolbar/toolbar-context/history-toolbar-state-context-provider.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React, { createContext, useState } from 'react' import type { HistoryToolbarStateWithDispatcher } from './toolbar-context' import { SortModeEnum } from '../../sort-button/sort-button' @@ -19,7 +20,7 @@ export const historyToolbarStateContext = createContext { +export const HistoryToolbarStateContextProvider: React.FC> = ({ children }) => { const urlParameterSearch = useSingleStringUrlParameter('search', '') const urlParameterSelectedTags = useArrayStringUrlParameter('selectedTags') diff --git a/src/components/landing-layout/landing-layout.tsx b/src/components/landing-layout/landing-layout.tsx index 2e7bd7eea..d393c0d46 100644 --- a/src/components/landing-layout/landing-layout.tsx +++ b/src/components/landing-layout/landing-layout.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React, { Fragment } from 'react' import { Container } from 'react-bootstrap' import { MotdModal } from '../common/motd-modal/motd-modal' @@ -11,7 +12,7 @@ import { Footer } from './footer/footer' import { HeaderBar } from './navigation/header-bar/header-bar' import { UiNotifications } from '../notifications/ui-notifications' -export const LandingLayout: React.FC = ({ children }) => { +export const LandingLayout: React.FC> = ({ children }) => { return ( diff --git a/src/components/landing-layout/navigation/header-bar/header-nav-link.tsx b/src/components/landing-layout/navigation/header-bar/header-nav-link.tsx index 9663eaaea..7eb53f625 100644 --- a/src/components/landing-layout/navigation/header-bar/header-nav-link.tsx +++ b/src/components/landing-layout/navigation/header-bar/header-nav-link.tsx @@ -5,6 +5,7 @@ */ import Link from 'next/link' +import type { PropsWithChildren } from 'react' import React, { useMemo } from 'react' import { Nav } from 'react-bootstrap' import type { PropsWithDataCypressId } from '../../../../utils/cypress-attribute' @@ -23,7 +24,7 @@ export interface HeaderNavLinkProps extends PropsWithDataCypressId { * @param children The react elements inside of link for more description * @param props Other navigation item props */ -export const HeaderNavLink: React.FC = ({ to, children, ...props }) => { +export const HeaderNavLink: React.FC> = ({ to, children, ...props }) => { const { route } = useRouter() const activeClass = useMemo(() => { diff --git a/src/components/login-page/auth/social-link-button/social-link-button.tsx b/src/components/login-page/auth/social-link-button/social-link-button.tsx index 3c1e335da..fc05462e7 100644 --- a/src/components/login-page/auth/social-link-button/social-link-button.tsx +++ b/src/components/login-page/auth/social-link-button/social-link-button.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import type { PropsWithChildren } from 'react' import React from 'react' import { ForkAwesomeIcon } from '../../../common/fork-awesome/fork-awesome-icon' import type { IconName } from '../../../common/fork-awesome/types' @@ -16,7 +17,13 @@ export interface SocialButtonProps { title?: string } -export const SocialLinkButton: React.FC = ({ title, backgroundClass, href, icon, children }) => { +export const SocialLinkButton: React.FC> = ({ + title, + backgroundClass, + href, + icon, + children +}) => { return ( = ({ +export const ClickShield: React.FC> = ({ containerClassName, onImageFetch, fallbackPreviewImageUrl,