-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I have used this library with React and TypeScript and created this typing definition to not have my compiler complain:
import { Component, ComponentLifecycle } from "react";
export declare function enableUniqueIds(component: Component): void;
export declare function resetUniqueIds(): void;
declare module "react" {
export interface Component<P = {}, S = {}, SS = any> extends ComponentLifecycle<P, S, SS> {
nextUniqueId(): string;
lastUniqueId(): string;
getUniqueId(identifier: string): string;
}
} It is possible another interface would be a better spot for this, however I have used this with React.PureComponent and observed the expected results (i.e. an element had id="id-2-1").
I used it by manually adding the typing definition file to node_modules. Here is a class with this in use TransformedImagesElement/src/components/editor/inputs/SwitchInput.tsx. Manually adding it is not ideal, which leads to two possible solutions:
- Add the typing definition directly to this module
- Add it to @types as a separate module: Contribution guide
KarinaShapran and ttilby
Metadata
Metadata
Assignees
Labels
No labels