Tell us what’s happening:
I am failing the following tests, however I’ve read through each of them and I believe that my work does actually fulfill these tests.
(Test 2) I can see an element with corresponding id=“preview”
(Test 3) When I enter text into the #editor element, the #preview element is updated as I type to display the content of the textarea
(Test 4) When I enter GitHub flavored markdown into the #editor element, the text is rendered as HTML in the #preview element as I type (Hint: You don’t need to parse Markdown yourself - you can import the Marked library for this: https://cdnjs.com/libraries/marked)
(Test 6) When my markdown previewer first loads, the default markdown in the #editor field should be rendered as HTML in the #preview element
Notably, test 5 (When my markdown previewer first loads, the default text in the #editor field should contain valid markdown that represents at least one of each of the following elements: a header (H1 size), a sub header (H2 size), a link, inline code, a code block, a list item, a blockquote, an image, and bolded text) works, which further puzzles me.
You need to wrap the markdown component inside an element with the preview id. You can’t put it on the component.
You can use the remark-breaks plug-in for the last test. Read the react-markdown docs to see how you add plug-ins (it is just a prop on the component).
For some reason, my project is now no longer passing Test 1: I can see a element with corresponding id=“editor”. It used to pass, but it doesn’t pass any longer.
The specific message provided is
‘’’ #editor is not defined : expected null to not equal null
‘’’
However, the #editor is clearly defined; I’ve wrapped the ‘’‘textarea’‘’ with the ‘’‘id=“editor”’‘’ in the ‘’‘render’‘’ method of class ‘’‘MyComponentWithButton’‘’.
Tests 3,4,5 and 6 still do not work, but I felt it is best to address the first test first, and then see if fixing this test provides a hint as to the others.
Also, there is no longer any output in the output display; I believe that this is some sort of glitch with my code, but I intend to fix this later after addressing the first failed test.
I also wanted to say thanks in advance for your help; I understand some of my questions might be somewhat basic, but I am hopeful that understanding these fundamentals will help me understand how to use React.
Use https://esm.sh instead of https://cdn.skypack.dev for the imports.
You should only have one root element in the HTML, that is where the parent component is mounted/rendered. It can’t use the preview id, which should be reserved for the markdown preview output element (you can not have the same id twice).
You do not need the MyComponent2 component at all.
You have to wrap the ReactMarkdown component inside an element with the preview id on it.