I'm trying to pass a Freecodecamp project. The project is a markdown previewer where you can enter code in a textarea and it renders it on the webpage. I have all the tests passing except two. It is supposed to preview the text on load and it does, but it rerenders and I'm not sure why. Can someone please take a look and tell me what I am doing wrong. I will have a link to my CodePen. I have two solutions that fail the same tests. One with react-hooks and one with a class component. I am using marked for the html parser. Thanks!
I am almost confident that it has something to do in the component with the textarea because that is one of the tests that is failing, but I can find anything wrong with it.
This is the text editor component:
const Editor = ({ text, setText }) => {
return (
<>
<textarea id='editor' value={ text } onChange={ (e) => setText(e.target.value) } />
</>
);
};
Here is the state with placeholder being a string of html:
const [ text, setText ] = React.useState(placeholder);
Your
placeholder
hashtml
, notmarkdown
inside it. You could try using something like this as yourplaceholder
and it should work