Hello everyone!
I make all the projects with create-react-app on VScode and with using hooks. My project has multiple files, since I practiced splitting the project on different components, so now I am stuck on how to upload my project into the codepen… I tried to copy-paste my code via console with EDIT HTML button, but it seams that after the transfer of the code- it doesn’t work properly… Please help me to find a solution either to upload my multiple-files react project into the codepen or please tell how to export html code … Thank you!
Your code so far
This is a link to my full github project:
Your browser information:
Brave
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36
Challenge: Front End Development Libraries Projects - Build a Markdown Previewer
meanwhile, if you want to know how to use multiple js fils in same “pen”, reading from this topic just might help, happy reading Two .js files in same pen?
I think I got it…
I used setState for editor as well, so there was some delay before my changes and input. That is why it didn’t work.
Moreover, I used html-react-parser to put inside my #editor element parsed data, but it should have done with “dangerouslySetInnerHTML” on #editor element directly - it worked.
Still 2 tests missed, but now I at least know when to search
6. When my markdown previewer first loads, the default markdown in the #editor field should be rendered as HTML in the #preview element
Before rendering the code, I review it and change with the function changeText, due to which this test cannot be passed.
It passed without changingText function (just the markdown) , but for curiosity purpose… Why doesn’t it work with my method? I change the string same as the markdown, but I just do it manually for studying purposes… Why this test fails when I try to use my own markdown?
tests were passed, but now my markup doesn’t work.
I mean, it work sometimes and sometimes not because of the prefix - it doesn’t take it’s place usually and when prefix works- is parsed…
import hljs from ‘highlight.js/lib/core’;
import javascript from ‘highlight.js/lib/languages/javascript’;
marked.parse second argument can be a callback, but you are calling the function fn(), not passing it fn.
The method you are using from highlight.js is deprecated.
Some of the highlight.js API doesn’t really work with that callback as they have value props (so you end up passing the value and not the function). You can use the highlight property on the marked option object instead (as shown in the marked docs).