AG-2914 DOCS - Add docs around react hooks with editors.

This commit is contained in:
Sean Landsman
2019-09-23 14:29:21 +01:00
parent 5a26863aff
commit b9b2b03a6b
3 changed files with 25 additions and 3 deletions

View File

@@ -0,0 +1,18 @@
import React, {useEffect, forwardRef, useImperativeHandle, useRef} from "react";
export default forwardRef((props, ref) => {
const inputRef = useRef();
useImperativeHandle(ref, () => {
return {
getValue: () => {
return inputRef.current.value;
}
};
});
useEffect(() => {
// https://github.com/facebook/react/issues/7835#issuecomment-395504863
setTimeout(() => inputRef.current.focus(), 10)
}, []);
return <input type="text" ref={inputRef} defaultValue={props.value}/>;
})