+ )}
+
+ {displayPreviewPortal && (
+
+ {preview}
+
+ )}
+ >
+ );
+ }
+}
+
+MobileLayout.displayName = 'MobileLayout';
+
+export default connect(mapStateToProps, mapDispatchToProps)(MobileLayout);
diff --git a/github_code/freeCodeCamp__freeCodeCamp/client/src/templates/Challenges/classic/multifile-editor.tsx b/github_code/freeCodeCamp__freeCodeCamp/client/src/templates/Challenges/classic/multifile-editor.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..de6881ff26dbd3930f15b4ab4250f5ef9ce9dacb
--- /dev/null
+++ b/github_code/freeCodeCamp__freeCodeCamp/client/src/templates/Challenges/classic/multifile-editor.tsx
@@ -0,0 +1,173 @@
+import React, { useRef } from 'react';
+import { connect } from 'react-redux';
+import { ReflexContainer, ReflexElement, ReflexSplitter } from 'react-reflex';
+import { createSelector } from 'reselect';
+import { isDonationModalOpenSelector } from '../../../redux/selectors';
+import {
+ canFocusEditorSelector,
+ visibleEditorsSelector
+} from '../redux/selectors';
+import { getTargetEditor } from '../utils/get-target-editor';
+import { isRtlLanguage } from '../../../utils/is-rtl-language';
+import './editor.css';
+import Editor, { type EditorProps } from './editor';
+
+export type VisibleEditors = {
+ indexhtml?: boolean;
+ indexjsx?: boolean;
+ stylescss?: boolean;
+ scriptjs?: boolean;
+ indexts?: boolean;
+ indextsx?: boolean;
+ mainpy?: boolean;
+ tsconfigjson?: boolean;
+};
+type MultifileEditorProps = Pick<
+ EditorProps,
+ | 'usesMultifileEditor'
+ | 'showProjectPreview'
+ | 'title'
+ | 'resizeProps'
+ | 'isUsingKeyboardInTablist'
+ | 'isMobileLayout'
+ | 'initialTests'
+ | 'editorRef'
+ | 'containerRef'
+ | 'block'
+ | 'superBlock'
+ | 'challengeFiles'
+ | 'description'
+ // We use dimensions to trigger a re-render of the editor
+ | 'dimensions'
+> & {
+ visibleEditors: VisibleEditors;
+};
+
+const mapStateToProps = createSelector(
+ visibleEditorsSelector,
+ canFocusEditorSelector,
+ isDonationModalOpenSelector,
+ (visibleEditors: VisibleEditors, canFocus: boolean, open) => ({
+ visibleEditors,
+ canFocus: open ? false : canFocus
+ })
+);
+
+const MultifileEditor = (props: MultifileEditorProps) => {
+ const {
+ block,
+ superBlock,
+ challengeFiles,
+ containerRef,
+ description,
+ editorRef,
+ initialTests,
+ isMobileLayout,
+ isUsingKeyboardInTablist,
+ resizeProps,
+ title,
+ visibleEditors: {
+ stylescss,
+ indexhtml,
+ scriptjs,
+ indexts,
+ indexjsx,
+ indextsx,
+ mainpy,
+ tsconfigjson
+ },
+ usesMultifileEditor,
+ showProjectPreview
+ } = props;
+ // TODO: the tabs mess up the rendering (scroll doesn't work properly and
+ // the in-editor description)
+
+ const reflexProps = {
+ propagateDimensions: true
+ };
+
+ const targetEditor = getTargetEditor(challengeFiles);
+
+ // Only one editor should be focused and that should happen once, after it has
+ // been mounted. This ref allows the editors to coordinate, without having to
+ // resort to redux.
+ const canFocusOnMountRef = useRef(true);
+
+ const editorKeys = [];
+
+ // The order of the keys should match the order set by sortChallengeFiles
+ if (indexjsx) editorKeys.push('indexjsx');
+ if (indextsx) editorKeys.push('indextsx');
+ if (indexhtml) editorKeys.push('indexhtml');
+ if (stylescss) editorKeys.push('stylescss');
+ if (scriptjs) editorKeys.push('scriptjs');
+ if (mainpy) editorKeys.push('mainpy');
+ if (indexts) editorKeys.push('indexts');
+ if (tsconfigjson) editorKeys.push('tsconfigjson');
+
+ const editorAndSplitterKeys = editorKeys.reduce((acc: string[] | [], key) => {
+ if (acc.length === 0) {
+ return [key];
+ } else {
+ return [...acc, `${key}-splitter`, key];
+ }
+ }, []);
+
+ if (isRtlLanguage) {
+ editorAndSplitterKeys.reverse();
+ }
+
+ return (
+
+
+
+ {editorAndSplitterKeys.map(key => {
+ const isSplitter = key.endsWith('-splitter');
+ if (isSplitter) {
+ return (
+
+ );
+ } else {
+ return (
+
+
+
+ );
+ }
+ })}
+
+
+
+ );
+};
+
+MultifileEditor.displayName = 'MultifileEditor';
+
+export default connect(mapStateToProps)(MultifileEditor);
diff --git a/github_code/freeCodeCamp__freeCodeCamp/client/src/templates/Challenges/classic/react-types-license b/github_code/freeCodeCamp__freeCodeCamp/client/src/templates/Challenges/classic/react-types-license
new file mode 100644
index 0000000000000000000000000000000000000000..48ea6616b5b8581df3401872996cecf1f8b08a0d
--- /dev/null
+++ b/github_code/freeCodeCamp__freeCodeCamp/client/src/templates/Challenges/classic/react-types-license
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) Microsoft Corporation.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE
diff --git a/github_code/freeCodeCamp__freeCodeCamp/client/src/templates/Challenges/classic/react-types.json b/github_code/freeCodeCamp__freeCodeCamp/client/src/templates/Challenges/classic/react-types.json
new file mode 100644
index 0000000000000000000000000000000000000000..c4e908a4c0efb6c2eb96d60d942b5549b23001a8
--- /dev/null
+++ b/github_code/freeCodeCamp__freeCodeCamp/client/src/templates/Challenges/classic/react-types.json
@@ -0,0 +1,3 @@
+{
+ "react-18": "// NOTE: Users of the `experimental` builds of React should add a reference\n// to 'react/experimental' in their project. See experimental.d.ts's top comment\n// for reference and documentation on how exactly to do it.\n\n/// \n\nimport * as CSS from \"csstype\";\nimport * as PropTypes from \"prop-types\";\n\ntype NativeAnimationEvent = AnimationEvent;\ntype NativeClipboardEvent = ClipboardEvent;\ntype NativeCompositionEvent = CompositionEvent;\ntype NativeDragEvent = DragEvent;\ntype NativeFocusEvent = FocusEvent;\ntype NativeInputEvent = InputEvent;\ntype NativeKeyboardEvent = KeyboardEvent;\ntype NativeMouseEvent = MouseEvent;\ntype NativeTouchEvent = TouchEvent;\ntype NativePointerEvent = PointerEvent;\ntype NativeTransitionEvent = TransitionEvent;\ntype NativeUIEvent = UIEvent;\ntype NativeWheelEvent = WheelEvent;\n\n/**\n * Used to represent DOM API's where users can either pass\n * true or false as a boolean or as its equivalent strings.\n */\ntype Booleanish = boolean | \"true\" | \"false\";\n\n/**\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin MDN}\n */\ntype CrossOrigin = \"anonymous\" | \"use-credentials\" | \"\" | undefined;\n\ndeclare const UNDEFINED_VOID_ONLY: unique symbol;\n\n/**\n * The function returned from an effect passed to {@link React.useEffect useEffect},\n * which can be used to clean up the effect when the component unmounts.\n *\n * @see {@link https://react.dev/reference/react/useEffect React Docs}\n */\ntype Destructor = () => void | { [UNDEFINED_VOID_ONLY]: never };\ntype VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };\n\n// eslint-disable-next-line @definitelytyped/export-just-namespace\nexport = React;\nexport as namespace React;\n\ndeclare namespace React {\n //\n // React Elements\n // ----------------------------------------------------------------------\n\n /**\n * Used to retrieve the possible components which accept a given set of props.\n *\n * Can be passed no type parameters to get a union of all possible components\n * and tags.\n *\n * Is a superset of {@link ComponentType}.\n *\n * @template P The props to match against. If not passed, defaults to any.\n * @template Tag An optional tag to match against. If not passed, attempts to match against all possible tags.\n *\n * @example\n *\n * ```tsx\n * // All components and tags (img, embed etc.)\n * // which accept `src`\n * type SrcComponents = ElementType<{ src: any }>;\n * ```\n *\n * @example\n *\n * ```tsx\n * // All components\n * type AllComponents = ElementType;\n * ```\n *\n * @example\n *\n * ```tsx\n * // All custom components which match `src`, and tags which\n * // match `src`, narrowed down to just `audio` and `embed`\n * type SrcComponents = ElementType<{ src: any }, 'audio' | 'embed'>;\n * ```\n */\n type ElementType
=\n | { [K in Tag]: P extends JSX.IntrinsicElements[K] ? K : never }[Tag]\n | ComponentType
;\n\n /**\n * Represents any user-defined component, either as a function or a class.\n *\n * Similar to {@link JSXElementConstructor}, but with extra properties like\n * {@link FunctionComponent.defaultProps defaultProps } and\n * {@link ComponentClass.contextTypes contextTypes}.\n *\n * @template P The props the component accepts.\n *\n * @see {@link ComponentClass}\n * @see {@link FunctionComponent}\n */\n type ComponentType
= ComponentClass
| FunctionComponent
;\n\n /**\n * Represents any user-defined component, either as a function or a class.\n *\n * Similar to {@link ComponentType}, but without extra properties like\n * {@link FunctionComponent.defaultProps defaultProps } and\n * {@link ComponentClass.contextTypes contextTypes}.\n *\n * @template P The props the component accepts.\n */\n type JSXElementConstructor
=\n | ((\n props: P,\n /**\n * @deprecated\n *\n * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-stateless-function-components React Docs}\n */\n deprecatedLegacyContext?: any,\n ) => ReactNode)\n | (new(\n props: P,\n /**\n * @deprecated\n *\n * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}\n */\n deprecatedLegacyContext?: any,\n ) => Component);\n\n /**\n * A readonly ref container where {@link current} cannot be mutated.\n *\n * Created by {@link createRef}, or {@link useRef} when passed `null`.\n *\n * @template T The type of the ref's value.\n *\n * @example\n *\n * ```tsx\n * const ref = createRef();\n *\n * ref.current = document.createElement('div'); // Error\n * ```\n */\n interface RefObject {\n /**\n * The current value of the ref.\n */\n readonly current: T | null;\n }\n\n interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES {\n }\n /**\n * A callback fired whenever the ref's value changes.\n *\n * @template T The type of the ref's value.\n *\n * @see {@link https://react.dev/reference/react-dom/components/common#ref-callback React Docs}\n *\n * @example\n *\n * ```tsx\n *
console.log(node)} />\n * ```\n */\n type RefCallback = {\n bivarianceHack(\n instance: T | null,\n ):\n | void\n | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[\n keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES\n ];\n }[\"bivarianceHack\"];\n\n /**\n * A union type of all possible shapes for React refs.\n *\n * @see {@link RefCallback}\n * @see {@link RefObject}\n */\n\n type Ref = RefCallback | RefObject | null;\n /**\n * A legacy implementation of refs where you can pass a string to a ref prop.\n *\n * @see {@link https://react.dev/reference/react/Component#refs React Docs}\n *\n * @example\n *\n * ```tsx\n * \n * ```\n */\n // TODO: Remove the string ref special case from `PropsWithRef` once we remove LegacyRef\n type LegacyRef = string | Ref;\n\n /**\n * Retrieves the type of the 'ref' prop for a given component type or tag name.\n *\n * @template C The component type.\n *\n * @example\n *\n * ```tsx\n * type MyComponentRef = React.ElementRef;\n * ```\n *\n * @example\n *\n * ```tsx\n * type DivRef = React.ElementRef<'div'>;\n * ```\n */\n type ElementRef<\n C extends\n | ForwardRefExoticComponent\n | { new(props: any): Component }\n | ((props: any, deprecatedLegacyContext?: any) => ReactNode)\n | keyof JSX.IntrinsicElements,\n > =\n // need to check first if `ref` is a valid prop for ts@3.0\n // otherwise it will infer `{}` instead of `never`\n \"ref\" extends keyof ComponentPropsWithRef\n ? NonNullable[\"ref\"]> extends RefAttributes<\n infer Instance\n >[\"ref\"] ? Instance\n : never\n : never;\n\n type ComponentState = any;\n\n /**\n * A value which uniquely identifies a node among items in an array.\n *\n * @see {@link https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key React Docs}\n */\n type Key = string | number | bigint;\n\n /**\n * @internal The props any component can receive.\n * You don't have to add this type. All components automatically accept these props.\n * ```tsx\n * const Component = () => ;\n * \n * ```\n *\n * WARNING: The implementation of a component will never have access to these attributes.\n * The following example would be incorrect usage because {@link Component} would never have access to `key`:\n * ```tsx\n * const Component = (props: React.Attributes) => props.key;\n * ```\n */\n interface Attributes {\n key?: Key | null | undefined;\n }\n /**\n * The props any component accepting refs can receive.\n * Class components, built-in browser components (e.g. `div`) and forwardRef components can receive refs and automatically accept these props.\n * ```tsx\n * const Component = forwardRef(() => );\n * console.log(current)} />\n * ```\n *\n * You only need this type if you manually author the types of props that need to be compatible with legacy refs.\n * ```tsx\n * interface Props extends React.RefAttributes {}\n * declare const Component: React.FunctionComponent;\n * ```\n *\n * Otherwise it's simpler to directly use {@link Ref} since you can safely use the\n * props type to describe to props that a consumer can pass to the component\n * as well as describing the props the implementation of a component \"sees\".\n * {@link RefAttributes} is generally not safe to describe both consumer and seen props.\n *\n * ```tsx\n * interface Props extends {\n * ref?: React.Ref | undefined;\n * }\n * declare const Component: React.FunctionComponent;\n * ```\n *\n * WARNING: The implementation of a component will not have access to the same type in versions of React supporting string refs.\n * The following example would be incorrect usage because {@link Component} would never have access to a `ref` with type `string`\n * ```tsx\n * const Component = (props: React.RefAttributes) => props.ref;\n * ```\n */\n interface RefAttributes extends Attributes {\n /**\n * Allows getting a ref to the component instance.\n * Once the component unmounts, React will set `ref.current` to `null`\n * (or call the ref with `null` if you passed a callback ref).\n *\n * @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}\n */\n ref?: LegacyRef | undefined;\n }\n\n /**\n * Represents the built-in attributes available to class components.\n */\n interface ClassAttributes extends RefAttributes {\n }\n\n /**\n * Represents a JSX element.\n *\n * Where {@link ReactNode} represents everything that can be rendered, `ReactElement`\n * only represents JSX.\n *\n * @template P The type of the props object\n * @template T The type of the component or tag\n *\n * @example\n *\n * ```tsx\n * const element: ReactElement = ;\n * ```\n */\n interface ReactElement<\n P = any,\n T extends string | JSXElementConstructor = string | JSXElementConstructor,\n > {\n type: T;\n props: P;\n key: string | null;\n }\n\n /**\n * @deprecated\n */\n interface ReactComponentElement<\n T extends keyof JSX.IntrinsicElements | JSXElementConstructor,\n P = Pick, Exclude, \"key\" | \"ref\">>,\n > extends ReactElement
> {}\n\n interface FunctionComponentElement
extends ReactElement
> {\n ref?: (\"ref\" extends keyof P ? P extends { ref?: infer R | undefined } ? R : never : never) | undefined;\n }\n\n type CElement
> = ComponentElement
;\n interface ComponentElement
> extends ReactElement
> {\n ref?: LegacyRef | undefined;\n }\n\n /**\n * @deprecated Use {@link ComponentElement} instead.\n */\n type ClassicElement
= CElement
>;\n\n // string fallback for custom web-components\n interface DOMElement
| SVGAttributes, T extends Element>\n extends ReactElement
{\n (props?: ClassAttributes & P | null, ...children: ReactNode[]): DetailedReactHTMLElement
;\n }\n\n /** @deprecated */\n interface SVGFactory extends DOMFactory, SVGElement> {\n (\n props?: ClassAttributes & SVGAttributes | null,\n ...children: ReactNode[]\n ): ReactSVGElement;\n }\n\n /**\n * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.\n */\n type ReactText = string | number;\n /**\n * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.\n */\n type ReactChild = ReactElement | string | number;\n\n /**\n * @deprecated Use either `ReactNode[]` if you need an array or `Iterable` if its passed to a host component.\n */\n interface ReactNodeArray extends ReadonlyArray {}\n /**\n * WARNING: Not related to `React.Fragment`.\n * @deprecated This type is not relevant when using React. Inline the type instead to make the intent clear.\n */\n type ReactFragment = Iterable;\n\n /**\n * Different release channels declare additional types of ReactNode this particular release channel accepts.\n * App or library types should never augment this interface.\n */\n interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES {}\n\n /**\n * Represents all of the things React can render.\n *\n * Where {@link ReactElement} only represents JSX, `ReactNode` represents everything that can be rendered.\n *\n * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/reactnode/ React TypeScript Cheatsheet}\n *\n * @example\n *\n * ```tsx\n * // Typing children\n * type Props = { children: ReactNode }\n *\n * const Component = ({ children }: Props) =>
} />\n * ```\n */\n // non-thenables need to be kept in sync with AwaitedReactNode\n type ReactNode =\n | ReactElement\n | string\n | number\n | Iterable\n | ReactPortal\n | boolean\n | null\n | undefined\n | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[\n keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES\n ];\n\n //\n // Top Level API\n // ----------------------------------------------------------------------\n\n // DOM Elements\n /** @deprecated */\n function createFactory(\n type: keyof ReactHTML,\n ): HTMLFactory;\n /** @deprecated */\n function createFactory(\n type: keyof ReactSVG,\n ): SVGFactory;\n /** @deprecated */\n function createFactory
, T extends Element>(\n type: string,\n ): DOMFactory
;\n\n // Custom components\n /** @deprecated */\n function createFactory
(type: FunctionComponent
): FunctionComponentFactory
;\n /** @deprecated */\n function createFactory
, C extends ComponentClass
>(\n type: ClassType
,\n ): CFactory
;\n /** @deprecated */\n function createFactory
(type: ComponentClass
): Factory
;\n\n // DOM Elements\n // TODO: generalize this to everything in `keyof ReactHTML`, not just \"input\"\n function createElement(\n type: \"input\",\n props?: InputHTMLAttributes & ClassAttributes | null,\n ...children: ReactNode[]\n ): DetailedReactHTMLElement, HTMLInputElement>;\n function createElement
, T extends HTMLElement>(\n type: keyof ReactHTML,\n props?: ClassAttributes & P | null,\n ...children: ReactNode[]\n ): DetailedReactHTMLElement
;\n function createElement
, T extends SVGElement>(\n type: keyof ReactSVG,\n props?: ClassAttributes & P | null,\n ...children: ReactNode[]\n ): ReactSVGElement;\n function createElement
, T extends Element>(\n type: string,\n props?: ClassAttributes & P | null,\n ...children: ReactNode[]\n ): DOMElement
;\n\n // Custom components\n\n function createElement
;\n // ReactHTMLElement, less specific\n function cloneElement
, T extends HTMLElement>(\n element: ReactHTMLElement,\n props?: P,\n ...children: ReactNode[]\n ): ReactHTMLElement;\n // SVGElement\n function cloneElement
, T extends SVGElement>(\n element: ReactSVGElement,\n props?: P,\n ...children: ReactNode[]\n ): ReactSVGElement;\n // DOM Element (has to be the last, because type checking stops at first overload that fits)\n function cloneElement
;\n\n /**\n * Describes the props accepted by a Context {@link Provider}.\n *\n * @template T The type of the value the context provides.\n */\n interface ProviderProps {\n value: T;\n children?: ReactNode | undefined;\n }\n\n /**\n * Describes the props accepted by a Context {@link Consumer}.\n *\n * @template T The type of the value the context provides.\n */\n interface ConsumerProps {\n children: (value: T) => ReactNode;\n }\n\n /**\n * An object masquerading as a component. These are created by functions\n * like {@link forwardRef}, {@link memo}, and {@link createContext}.\n *\n * In order to make TypeScript work, we pretend that they are normal\n * components.\n *\n * But they are, in fact, not callable - instead, they are objects which\n * are treated specially by the renderer.\n *\n * @template P The props the component accepts.\n */\n interface ExoticComponent
{\n (props: P): ReactNode;\n readonly $$typeof: symbol;\n }\n\n /**\n * An {@link ExoticComponent} with a `displayName` property applied to it.\n *\n * @template P The props the component accepts.\n */\n interface NamedExoticComponent
extends ExoticComponent
{\n /**\n * Used in debugging messages. You might want to set it\n * explicitly if you want to display a different name for\n * debugging purposes.\n *\n * @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}\n */\n displayName?: string | undefined;\n }\n\n /**\n * An {@link ExoticComponent} with a `propTypes` property applied to it.\n *\n * @template P The props the component accepts.\n */\n interface ProviderExoticComponent
extends ExoticComponent
{\n propTypes?: WeakValidationMap
| undefined;\n }\n\n /**\n * Used to retrieve the type of a context object from a {@link Context}.\n *\n * @template C The context object.\n *\n * @example\n *\n * ```tsx\n * import { createContext } from 'react';\n *\n * const MyContext = createContext({ foo: 'bar' });\n *\n * type ContextType = ContextType;\n * // ContextType = { foo: string }\n * ```\n */\n type ContextType> = C extends Context ? T : never;\n\n /**\n * Wraps your components to specify the value of this context for all components inside.\n *\n * @see {@link https://react.dev/reference/react/createContext#provider React Docs}\n *\n * @example\n *\n * ```tsx\n * import { createContext } from 'react';\n *\n * const ThemeContext = createContext('light');\n *\n * function App() {\n * return (\n * \n * \n * \n * );\n * }\n * ```\n */\n type Provider = ProviderExoticComponent>;\n\n /**\n * The old way to read context, before {@link useContext} existed.\n *\n * @see {@link https://react.dev/reference/react/createContext#consumer React Docs}\n *\n * @example\n *\n * ```tsx\n * import { UserContext } from './user-context';\n *\n * function Avatar() {\n * return (\n * \n * {user => }\n * \n * );\n * }\n * ```\n */\n type Consumer = ExoticComponent>;\n\n /**\n * Context lets components pass information deep down without explicitly\n * passing props.\n *\n * Created from {@link createContext}\n *\n * @see {@link https://react.dev/learn/passing-data-deeply-with-context React Docs}\n * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet}\n *\n * @example\n *\n * ```tsx\n * import { createContext } from 'react';\n *\n * const ThemeContext = createContext('light');\n * ```\n */\n interface Context {\n Provider: Provider;\n Consumer: Consumer;\n /**\n * Used in debugging messages. You might want to set it\n * explicitly if you want to display a different name for\n * debugging purposes.\n *\n * @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}\n */\n displayName?: string | undefined;\n }\n\n /**\n * Lets you create a {@link Context} that components can provide or read.\n *\n * @param defaultValue The value you want the context to have when there is no matching\n * {@link Provider} in the tree above the component reading the context. This is meant\n * as a \"last resort\" fallback.\n *\n * @see {@link https://react.dev/reference/react/createContext#reference React Docs}\n * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet}\n *\n * @example\n *\n * ```tsx\n * import { createContext } from 'react';\n *\n * const ThemeContext = createContext('light');\n * ```\n */\n function createContext(\n // If you thought this should be optional, see\n // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24509#issuecomment-382213106\n defaultValue: T,\n ): Context;\n\n function isValidElement
(object: {} | null | undefined): object is ReactElement
;\n\n /**\n * Maintainer's note: Sync with {@link ReactChildren} until {@link ReactChildren} is removed.\n */\n const Children: {\n map(\n children: C | readonly C[],\n fn: (child: C, index: number) => T,\n ): C extends null | undefined ? C : Array>;\n forEach(children: C | readonly C[], fn: (child: C, index: number) => void): void;\n count(children: any): number;\n only(children: C): C extends any[] ? never : C;\n toArray(children: ReactNode | ReactNode[]): Array>;\n };\n /**\n * Lets you group elements without a wrapper node.\n *\n * @see {@link https://react.dev/reference/react/Fragment React Docs}\n *\n * @example\n *\n * ```tsx\n * import { Fragment } from 'react';\n *\n * \n *
\n * >\n * ```\n */\n const Fragment: ExoticComponent<{ children?: ReactNode | undefined }>;\n\n /**\n * Lets you find common bugs in your components early during development.\n *\n * @see {@link https://react.dev/reference/react/StrictMode React Docs}\n *\n * @example\n *\n * ```tsx\n * import { StrictMode } from 'react';\n *\n * \n * \n * \n * ```\n */\n const StrictMode: ExoticComponent<{ children?: ReactNode | undefined }>;\n\n /**\n * The props accepted by {@link Suspense}.\n *\n * @see {@link https://react.dev/reference/react/Suspense React Docs}\n */\n interface SuspenseProps {\n children?: ReactNode | undefined;\n\n /** A fallback react tree to show when a Suspense child (like React.lazy) suspends */\n fallback?: ReactNode;\n\n /**\n * A name for this Suspense boundary for instrumentation purposes.\n * The name will help identify this boundary in React DevTools.\n */\n name?: string | undefined;\n }\n\n /**\n * Lets you display a fallback until its children have finished loading.\n *\n * @see {@link https://react.dev/reference/react/Suspense React Docs}\n *\n * @example\n *\n * ```tsx\n * import { Suspense } from 'react';\n *\n * }>\n * \n * \n * ```\n */\n const Suspense: ExoticComponent;\n const version: string;\n\n /**\n * The callback passed to {@link ProfilerProps.onRender}.\n *\n * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}\n */\n type ProfilerOnRenderCallback = (\n /**\n * The string id prop of the {@link Profiler} tree that has just committed. This lets\n * you identify which part of the tree was committed if you are using multiple\n * profilers.\n *\n * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}\n */\n id: string,\n /**\n * This lets you know whether the tree has just been mounted for the first time\n * or re-rendered due to a change in props, state, or hooks.\n *\n * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}\n */\n phase: \"mount\" | \"update\" | \"nested-update\",\n /**\n * The number of milliseconds spent rendering the {@link Profiler} and its descendants\n * for the current update. This indicates how well the subtree makes use of\n * memoization (e.g. {@link memo} and {@link useMemo}). Ideally this value should decrease\n * significantly after the initial mount as many of the descendants will only need to\n * re-render if their specific props change.\n *\n * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}\n */\n actualDuration: number,\n /**\n * The number of milliseconds estimating how much time it would take to re-render the entire\n * {@link Profiler} subtree without any optimizations. It is calculated by summing up the most\n * recent render durations of each component in the tree. This value estimates a worst-case\n * cost of rendering (e.g. the initial mount or a tree with no memoization). Compare\n * {@link actualDuration} against it to see if memoization is working.\n *\n * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}\n */\n baseDuration: number,\n /**\n * A numeric timestamp for when React began rendering the current update.\n *\n * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}\n */\n startTime: number,\n /**\n * A numeric timestamp for when React committed the current update. This value is shared\n * between all profilers in a commit, enabling them to be grouped if desirable.\n *\n * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}\n */\n commitTime: number,\n ) => void;\n\n /**\n * The props accepted by {@link Profiler}.\n *\n * @see {@link https://react.dev/reference/react/Profiler React Docs}\n */\n interface ProfilerProps {\n children?: ReactNode | undefined;\n id: string;\n onRender: ProfilerOnRenderCallback;\n }\n\n /**\n * Lets you measure rendering performance of a React tree programmatically.\n *\n * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}\n *\n * @example\n *\n * ```tsx\n * \n * \n * \n * ```\n */\n const Profiler: ExoticComponent;\n\n //\n // Component API\n // ----------------------------------------------------------------------\n\n type ReactInstance = Component | Element;\n\n // Base component for plain JS classes\n interface Component
extends ComponentLifecycle
{}\n class Component
{\n /**\n * If set, `this.context` will be set at runtime to the current value of the given Context.\n *\n * @example\n *\n * ```ts\n * type MyContext = number\n * const Ctx = React.createContext(0)\n *\n * class Foo extends React.Component {\n * static contextType = Ctx\n * context!: React.ContextType\n * render () {\n * return <>My context's value: {this.context}>;\n * }\n * }\n * ```\n *\n * @see {@link https://react.dev/reference/react/Component#static-contexttype}\n */\n static contextType?: Context | undefined;\n\n /**\n * If using the new style context, re-declare this in your class to be the\n * `React.ContextType` of your `static contextType`.\n * Should be used with type annotation or static contextType.\n *\n * @example\n * ```ts\n * static contextType = MyContext\n * // For TS pre-3.7:\n * context!: React.ContextType\n * // For TS 3.7 and above:\n * declare context: React.ContextType\n * ```\n *\n * @see {@link https://react.dev/reference/react/Component#context React Docs}\n */\n context: unknown;\n\n constructor(props: P);\n /**\n * @deprecated\n * @see {@link https://legacy.reactjs.org/docs/legacy-context.html React Docs}\n */\n constructor(props: P, context: any);\n\n // We MUST keep setState() as a unified signature because it allows proper checking of the method return type.\n // See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257\n // Also, the ` | S` allows intellisense to not be dumbisense\n setState(\n state: ((prevState: Readonly, props: Readonly
;\n\n /**\n * Represents the type of a function component. Can optionally\n * receive a type argument that represents the props the component\n * accepts.\n *\n * @template P The props the component accepts.\n * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components React TypeScript Cheatsheet}\n *\n * @example\n *\n * ```tsx\n * // With props:\n * type Props = { name: string }\n *\n * const MyComponent: FunctionComponent = (props) => {\n * return
{\n (\n props: P,\n /**\n * @deprecated\n *\n * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}\n */\n deprecatedLegacyContext?: any,\n ): ReactNode;\n /**\n * Used to declare the types of the props accepted by the\n * component. These types will be checked during rendering\n * and in development only.\n *\n * We recommend using TypeScript instead of checking prop\n * types at runtime.\n *\n * @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}\n */\n propTypes?: WeakValidationMap
| undefined;\n /**\n * @deprecated\n *\n * Lets you specify which legacy context is consumed by\n * this component.\n *\n * @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}\n */\n contextTypes?: ValidationMap | undefined;\n /**\n * Used to define default values for the props accepted by\n * the component.\n *\n * @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}\n *\n * @example\n *\n * ```tsx\n * type Props = { name?: string }\n *\n * const MyComponent: FC = (props) => {\n * return
| undefined;\n /**\n * Used in debugging messages. You might want to set it\n * explicitly if you want to display a different name for\n * debugging purposes.\n *\n * @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}\n *\n * @example\n *\n * ```tsx\n *\n * const MyComponent: FC = () => {\n * return
| undefined;\n contextTypes?: ValidationMap | undefined;\n /**\n * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.\n */\n defaultProps?: Partial
| undefined;\n displayName?: string | undefined;\n }\n\n /**\n * The type of the ref received by a {@link ForwardRefRenderFunction}.\n *\n * @see {@link ForwardRefRenderFunction}\n */\n type ForwardedRef = ((instance: T | null) => void) | MutableRefObject | null;\n\n /**\n * The type of the function passed to {@link forwardRef}. This is considered different\n * to a normal {@link FunctionComponent} because it receives an additional argument,\n *\n * @param props Props passed to the component, if any.\n * @param ref A ref forwarded to the component of type {@link ForwardedRef}.\n *\n * @template T The type of the forwarded ref.\n * @template P The type of the props the component accepts.\n *\n * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/forward_and_create_ref/ React TypeScript Cheatsheet}\n * @see {@link forwardRef}\n */\n interface ForwardRefRenderFunction {\n (props: P, ref: ForwardedRef): ReactNode;\n /**\n * Used in debugging messages. You might want to set it\n * explicitly if you want to display a different name for\n * debugging purposes.\n *\n * Will show `ForwardRef(${Component.displayName || Component.name})`\n * in devtools by default, but can be given its own specific name.\n *\n * @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}\n */\n displayName?: string | undefined;\n /**\n * defaultProps are not supported on render functions passed to forwardRef.\n *\n * @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context\n * @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}\n */\n defaultProps?: never | undefined;\n /**\n * propTypes are not supported on render functions passed to forwardRef.\n *\n * @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context\n * @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}\n */\n propTypes?: never | undefined;\n }\n\n /**\n * Represents a component class in React.\n *\n * @template P The props the component accepts.\n * @template S The internal state of the component.\n */\n interface ComponentClass
;\n /**\n * Used to declare the types of the props accepted by the\n * component. These types will be checked during rendering\n * and in development only.\n *\n * We recommend using TypeScript instead of checking prop\n * types at runtime.\n *\n * @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}\n */\n propTypes?: WeakValidationMap
| undefined;\n contextType?: Context | undefined;\n /**\n * @deprecated use {@link ComponentClass.contextType} instead\n *\n * Lets you specify which legacy context is consumed by\n * this component.\n *\n * @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}\n */\n contextTypes?: ValidationMap | undefined;\n /**\n * @deprecated\n *\n * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#how-to-use-context Legacy React Docs}\n */\n childContextTypes?: ValidationMap | undefined;\n /**\n * Used to define default values for the props accepted by\n * the component.\n *\n * @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}\n */\n defaultProps?: Partial
| undefined;\n /**\n * Used in debugging messages. You might want to set it\n * explicitly if you want to display a different name for\n * debugging purposes.\n *\n * @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}\n */\n displayName?: string | undefined;\n }\n\n /**\n * @deprecated Use `ClassicComponentClass` from `create-react-class`\n *\n * @see {@link https://legacy.reactjs.org/docs/react-without-es6.html Legacy React Docs}\n * @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}\n */\n interface ClassicComponentClass
;\n getDefaultProps?(): P;\n }\n\n /**\n * Used in {@link createElement} and {@link createFactory} to represent\n * a class.\n *\n * An intersection type is used to infer multiple type parameters from\n * a single argument, which is useful for many top-level API defs.\n * See {@link https://github.com/Microsoft/TypeScript/issues/7234 this GitHub issue}\n * for more info.\n */\n type ClassType
, C extends ComponentClass
> =\n & C\n & (new(props: P, deprecatedLegacyContext?: any) => T);\n\n //\n // Component Specs and Lifecycle\n // ----------------------------------------------------------------------\n\n // This should actually be something like `Lifecycle
| DeprecatedLifecycle
`,\n // as React will _not_ call the deprecated lifecycle methods if any of the new lifecycle\n // methods are present.\n interface ComponentLifecycle
extends NewLifecycle
, DeprecatedLifecycle
{\n /**\n * Called immediately after a component is mounted. Setting state here will trigger re-rendering.\n */\n componentDidMount?(): void;\n /**\n * Called to determine whether the change in props and state should trigger a re-render.\n *\n * `Component` always returns true.\n * `PureComponent` implements a shallow comparison on props and state and returns true if any\n * props or states have changed.\n *\n * If false is returned, {@link Component.render}, `componentWillUpdate`\n * and `componentDidUpdate` will not be called.\n */\n shouldComponentUpdate?(nextProps: Readonly
, nextState: Readonly, nextContext: any): boolean;\n /**\n * Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as\n * cancelled network requests, or cleaning up any DOM elements created in `componentDidMount`.\n */\n componentWillUnmount?(): void;\n /**\n * Catches exceptions generated in descendant components. Unhandled exceptions will cause\n * the entire component tree to unmount.\n */\n componentDidCatch?(error: Error, errorInfo: ErrorInfo): void;\n }\n\n // Unfortunately, we have no way of declaring that the component constructor must implement this\n interface StaticLifecycle
| undefined;\n }\n\n type GetDerivedStateFromProps
=\n /**\n * Returns an update to a component's state based on its new props and old state.\n *\n * Note: its presence prevents any of the deprecated lifecycle methods from being invoked\n */\n (nextProps: Readonly
, prevState: S) => Partial | null;\n\n type GetDerivedStateFromError
=\n /**\n * This lifecycle is invoked after an error has been thrown by a descendant component.\n * It receives the error that was thrown as a parameter and should return a value to update state.\n *\n * Note: its presence prevents any of the deprecated lifecycle methods from being invoked\n */\n (error: any) => Partial | null;\n\n // This should be \"infer SS\" but can't use it yet\n interface NewLifecycle
{\n /**\n * Runs before React applies the result of {@link Component.render render} to the document, and\n * returns an object to be given to {@link componentDidUpdate}. Useful for saving\n * things such as scroll position before {@link Component.render render} causes changes to it.\n *\n * Note: the presence of this method prevents any of the deprecated\n * lifecycle events from running.\n */\n getSnapshotBeforeUpdate?(prevProps: Readonly
, prevState: Readonly): SS | null;\n /**\n * Called immediately after updating occurs. Not called for the initial render.\n *\n * The snapshot is only present if {@link getSnapshotBeforeUpdate} is present and returns non-null.\n */\n componentDidUpdate?(prevProps: Readonly
{\n /**\n * Called immediately before mounting occurs, and before {@link Component.render}.\n * Avoid introducing any side-effects or subscriptions in this method.\n *\n * Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}\n * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents\n * this from being invoked.\n *\n * @deprecated 16.3, use {@link ComponentLifecycle.componentDidMount componentDidMount} or the constructor instead; will stop working in React 17\n * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state}\n * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}\n */\n componentWillMount?(): void;\n /**\n * Called immediately before mounting occurs, and before {@link Component.render}.\n * Avoid introducing any side-effects or subscriptions in this method.\n *\n * This method will not stop working in React 17.\n *\n * Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}\n * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents\n * this from being invoked.\n *\n * @deprecated 16.3, use {@link ComponentLifecycle.componentDidMount componentDidMount} or the constructor instead\n * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state}\n * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}\n */\n UNSAFE_componentWillMount?(): void;\n /**\n * Called when the component may be receiving new props.\n * React may call this even if props have not changed, so be sure to compare new and existing\n * props if you only want to handle changes.\n *\n * Calling {@link Component.setState} generally does not trigger this method.\n *\n * Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}\n * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents\n * this from being invoked.\n *\n * @deprecated 16.3, use static {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} instead; will stop working in React 17\n * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}\n * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}\n */\n componentWillReceiveProps?(nextProps: Readonly
, nextContext: any): void;\n /**\n * Called when the component may be receiving new props.\n * React may call this even if props have not changed, so be sure to compare new and existing\n * props if you only want to handle changes.\n *\n * Calling {@link Component.setState} generally does not trigger this method.\n *\n * This method will not stop working in React 17.\n *\n * Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}\n * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents\n * this from being invoked.\n *\n * @deprecated 16.3, use static {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} instead\n * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}\n * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}\n */\n UNSAFE_componentWillReceiveProps?(nextProps: Readonly
, nextContext: any): void;\n /**\n * Called immediately before rendering when new props or state is received. Not called for the initial render.\n *\n * Note: You cannot call {@link Component.setState} here.\n *\n * Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}\n * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents\n * this from being invoked.\n *\n * @deprecated 16.3, use getSnapshotBeforeUpdate instead; will stop working in React 17\n * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}\n * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}\n */\n componentWillUpdate?(nextProps: Readonly
, nextState: Readonly, nextContext: any): void;\n /**\n * Called immediately before rendering when new props or state is received. Not called for the initial render.\n *\n * Note: You cannot call {@link Component.setState} here.\n *\n * This method will not stop working in React 17.\n *\n * Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}\n * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents\n * this from being invoked.\n *\n * @deprecated 16.3, use getSnapshotBeforeUpdate instead\n * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}\n * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}\n */\n UNSAFE_componentWillUpdate?(nextProps: Readonly
{\n render(): ReactNode;\n\n [propertyName: string]: any;\n }\n\n function createRef(): RefObject;\n\n /**\n * The type of the component returned from {@link forwardRef}.\n *\n * @template P The props the component accepts, if any.\n *\n * @see {@link ExoticComponent}\n */\n interface ForwardRefExoticComponent
extends NamedExoticComponent
{\n /**\n * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.\n */\n defaultProps?: Partial
| undefined;\n propTypes?: WeakValidationMap
| undefined;\n }\n\n /**\n * Lets your component expose a DOM node to a parent component\n * using a ref.\n *\n * @see {@link https://react.dev/reference/react/forwardRef React Docs}\n * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/forward_and_create_ref/ React TypeScript Cheatsheet}\n *\n * @param render See the {@link ForwardRefRenderFunction}.\n *\n * @template T The type of the DOM node.\n * @template P The props the component accepts, if any.\n *\n * @example\n *\n * ```tsx\n * interface Props {\n * children?: ReactNode;\n * type: \"submit\" | \"button\";\n * }\n *\n * export const FancyButton = forwardRef((props, ref) => (\n * \n * ));\n * ```\n */\n function forwardRef(\n render: ForwardRefRenderFunction>,\n ): ForwardRefExoticComponent & RefAttributes>;\n\n /**\n * Omits the 'ref' attribute from the given props object.\n *\n * @template P The props object type.\n */\n type PropsWithoutRef
=\n // Omit would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.\n // see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types\n // https://github.com/Microsoft/TypeScript/issues/28339\n P extends any ? (\"ref\" extends keyof P ? Omit
: P) : P;\n /** Ensures that the props do not include string ref, which cannot be forwarded */\n type PropsWithRef
=\n // Note: String refs can be forwarded. We can't fix this bug without breaking a bunch of libraries now though.\n // Just \"P extends { ref?: infer R }\" looks sufficient, but R will infer as {} if P is {}.\n \"ref\" extends keyof P\n ? P extends { ref?: infer R | undefined }\n ? string extends R ? PropsWithoutRef
= P & { children?: ReactNode | undefined };\n\n /**\n * Used to retrieve the props a component accepts. Can either be passed a string,\n * indicating a DOM element (e.g. 'div', 'span', etc.) or the type of a React\n * component.\n *\n * It's usually better to use {@link ComponentPropsWithRef} or {@link ComponentPropsWithoutRef}\n * instead of this type, as they let you be explicit about whether or not to include\n * the `ref` prop.\n *\n * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/ React TypeScript Cheatsheet}\n *\n * @example\n *\n * ```tsx\n * // Retrieves the props an 'input' element accepts\n * type InputProps = React.ComponentProps<'input'>;\n * ```\n *\n * @example\n *\n * ```tsx\n * const MyComponent = (props: { foo: number, bar: string }) =>
;\n *\n * // Retrieves the props 'MyComponent' accepts\n * type MyComponentProps = React.ComponentProps;\n * ```\n */\n type ComponentProps> = T extends\n JSXElementConstructor ? P\n : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]\n : {};\n\n /**\n * Used to retrieve the props a component accepts with its ref. Can either be\n * passed a string, indicating a DOM element (e.g. 'div', 'span', etc.) or the\n * type of a React component.\n *\n * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/ React TypeScript Cheatsheet}\n *\n * @example\n *\n * ```tsx\n * // Retrieves the props an 'input' element accepts\n * type InputProps = React.ComponentPropsWithRef<'input'>;\n * ```\n *\n * @example\n *\n * ```tsx\n * const MyComponent = (props: { foo: number, bar: string }) => ;\n *\n * // Retrieves the props 'MyComponent' accepts\n * type MyComponentPropsWithRef = React.ComponentPropsWithRef;\n * ```\n */\n type ComponentPropsWithRef = T extends (new(props: infer P) => Component)\n ? PropsWithoutRef
& RefAttributes>\n : PropsWithRef>;\n /**\n * Used to retrieve the props a custom component accepts with its ref.\n *\n * Unlike {@link ComponentPropsWithRef}, this only works with custom\n * components, i.e. components you define yourself. This is to improve\n * type-checking performance.\n *\n * @example\n *\n * ```tsx\n * const MyComponent = (props: { foo: number, bar: string }) => ;\n *\n * // Retrieves the props 'MyComponent' accepts\n * type MyComponentPropsWithRef = React.CustomComponentPropsWithRef;\n * ```\n */\n type CustomComponentPropsWithRef = T extends (new(props: infer P) => Component)\n ? (PropsWithoutRef
\n : never;\n\n /**\n * Used to retrieve the props a component accepts without its ref. Can either be\n * passed a string, indicating a DOM element (e.g. 'div', 'span', etc.) or the\n * type of a React component.\n *\n * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/ React TypeScript Cheatsheet}\n *\n * @example\n *\n * ```tsx\n * // Retrieves the props an 'input' element accepts\n * type InputProps = React.ComponentPropsWithoutRef<'input'>;\n * ```\n *\n * @example\n *\n * ```tsx\n * const MyComponent = (props: { foo: number, bar: string }) =>
;\n *\n * // Retrieves the props 'MyComponent' accepts\n * type MyComponentPropsWithoutRef = React.ComponentPropsWithoutRef;\n * ```\n */\n type ComponentPropsWithoutRef = PropsWithoutRef>;\n\n type ComponentRef = T extends NamedExoticComponent<\n ComponentPropsWithoutRef & RefAttributes\n > ? Method\n : ComponentPropsWithRef extends RefAttributes ? Method\n : never;\n\n // will show `Memo(${Component.displayName || Component.name})` in devtools by default,\n // but can be given its own specific name\n type MemoExoticComponent> = NamedExoticComponent> & {\n readonly type: T;\n };\n\n /**\n * Lets you skip re-rendering a component when its props are unchanged.\n *\n * @see {@link https://react.dev/reference/react/memo React Docs}\n *\n * @param Component The component to memoize.\n * @param propsAreEqual A function that will be used to determine if the props have changed.\n *\n * @example\n *\n * ```tsx\n * import { memo } from 'react';\n *\n * const SomeComponent = memo(function SomeComponent(props: { foo: string }) {\n * // ...\n * });\n * ```\n */\n function memo