This repository was archived by the owner on Jan 20, 2022. It is now read-only.
How to call getHeadings() #519
Answered
by
jnahumphreys
jnahumphreys
asked this question in
Q&A
-
Hi I can see via the docs that the Can someone provide some help with getting the headings via this API within a function based component (i.e non class based). I've tried the suggested passing of a ref as per this question, with not much luck. // When passing some markdown content with headings
function EditorTest() {
const editorInstance = useRef();
const headings = editorInstance.current?.getHeadings();
console.log(headings); // returns undefined
return (
<Editor defaultValue={markdownContent} ref={editorInstance} />
);
} Thanks in advance |
Beta Was this translation helpful? Give feedback.
Answered by
jnahumphreys
Aug 9, 2021
Replies: 1 comment
-
... I think I've worked this out, can close // When passing some markdown content with headings
function EditorTest() {
const editorInstance = useRef();
useEffect(() => {
const headings = editorInstance.current?.getHeadings();
console.log(headings); // returns array of headings
});
return (
<Editor defaultValue={markdownContent} ref={editorInstance} />
);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jnahumphreys
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
... I think I've worked this out, can close