diff --git a/types/react-mentions/index.d.ts b/types/react-mentions/index.d.ts index ff10bbc013..ec9716aad7 100644 --- a/types/react-mentions/index.d.ts +++ b/types/react-mentions/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for react-mentions 2.3 +// Type definitions for react-mentions 2.4 // Project: https://github.com/signavio/react-mentions // Definitions by: Scott Willeke +// Eugene Fedorenko // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 import * as React from "react"; @@ -41,12 +42,16 @@ export interface MentionsInputProps { style?: any; regex?: RegExp; suggestionsPortalHost?: Element; + inputRef?: React.RefObject | React.RefObject; } /** * Exposes the type for use with the @see MentionsInputComponent.wrappedInstance which is added by react-mentions' use of substyle (https://github.com/jfschwarz/substyle). */ export interface MentionsInputComponentUnrwapped extends React.Component { + /** + * @deprecated since version 2.4.0. Please use @see MentionsInputProps.inputRef + */ inputRef?: HTMLInputElement | HTMLTextAreaElement; } diff --git a/types/react-mentions/react-mentions-tests.tsx b/types/react-mentions/react-mentions-tests.tsx index 49f5180720..7611b29384 100644 --- a/types/react-mentions/react-mentions-tests.tsx +++ b/types/react-mentions/react-mentions-tests.tsx @@ -11,19 +11,32 @@ interface TestProps { } export const TestSimple: React.SFC = (props) => { + const inputEl = React.createRef(); + + function handleClick() { + if (inputEl.current) { + inputEl.current.focus(); + } + } + return ( - `@${login}`} - > - - + <> + `@${login}`} + inputRef={inputEl} + > + + + + + ); }; diff --git a/types/react-mentions/tsconfig.json b/types/react-mentions/tsconfig.json index 260c003e2d..973ede82b7 100644 --- a/types/react-mentions/tsconfig.json +++ b/types/react-mentions/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", "dom" ], "noImplicitAny": true, "noImplicitThis": true,