Skip to content

Commit d51d9da

Browse files
committed
fix(SlateAsInputEditor): still create ref is one is not forwarded
Signed-off-by: Diana Lease <dianarlease@gmail.com>
1 parent 1aac73f commit d51d9da

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/SlateAsInputEditor/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import React, {
1616
useEffect,
1717
useState,
18+
useRef,
1819
useCallback
1920
}
2021
from 'react';
@@ -91,7 +92,7 @@ function uuidv4() {
9192
* for details.
9293
*/
9394
// eslint-disable-next-line react/display-name
94-
const SlateAsInputEditor = React.forwardRef((props, editorRef) => {
95+
const SlateAsInputEditor = React.forwardRef((props, ref) => {
9596
/**
9697
* Destructure props for efficiency
9798
*/
@@ -101,6 +102,11 @@ const SlateAsInputEditor = React.forwardRef((props, editorRef) => {
101102

102103
const editorProps = props.editorProps || Object.create(null);
103104

105+
/**
106+
* A reference to the Slate Editor.
107+
*/
108+
const editorRef = ref || useRef(null);
109+
104110
/**
105111
* Slate Schema augmented by plugins
106112
*/

0 commit comments

Comments
 (0)