Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #76 from accordproject/dl-forward-ref
Browse files Browse the repository at this point in the history
 feat(SlateAsInputEditor): forward ref to the Slate Editor
  • Loading branch information
DianaLease authored Aug 15, 2019
2 parents 3904f68 + d51d9da commit 9fb6b7a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/SlateAsInputEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ function uuidv4() {
* @param {*} props the props for the component. See the declared PropTypes
* for details.
*/
function SlateAsInputEditor(props) {
// eslint-disable-next-line react/display-name
const SlateAsInputEditor = React.forwardRef((props, ref) => {
/**
* Destructure props for efficiency
*/
Expand All @@ -104,7 +105,7 @@ function SlateAsInputEditor(props) {
/**
* A reference to the Slate Editor.
*/
const editorRef = useRef(null);
const editorRef = ref || useRef(null);

/**
* Slate Schema augmented by plugins
Expand Down Expand Up @@ -141,7 +142,6 @@ function SlateAsInputEditor(props) {
augmentedSchema = plugin.augmentSchema(augmentedSchema);
}
});
console.log('Slate schema', augmentedSchema);
setSlateSchema(augmentedSchema);
}, [plugins]);

Expand Down Expand Up @@ -173,7 +173,7 @@ function SlateAsInputEditor(props) {
}
});
}
}, [value.document, lockText]);
}, [value.document, lockText, editorRef]);

/**
* Render a Slate inline.
Expand Down Expand Up @@ -443,7 +443,7 @@ function SlateAsInputEditor(props) {
</EditorWrapper>
</div>
);
}
});

/**
* The property types for this component
Expand Down

0 comments on commit 9fb6b7a

Please sign in to comment.