Need help! React App is not working in CodePen

Hi Everyone,

I made Markdown previewer in Vscode and it was working completely fine. Now, I am trying to put the code in CodePen. I have made the necessary changes, but still my react app is not showing up. Could anyone please have a look into this and help me out.

Link: Markdown Previewer CodePen


There is nothing wrong with your markdown - it is a JS problem in a library, I think.

When I open up your console window, I see:

TypeError: Cannot read property ‘replace’ of undefined
Please report this to
at Lexer.lex (marked.js:138)
// …

So, that is an issue in with marked. You are calling marked, it is in the render method of MarkdownPreviewer with marked(props.markdown). If I put console.log(props.markdown); on the line before the return for that method, I see that it is undefined. My guess is that that marked function is expecting something other than undefined.

1 Like

Thanks @kevinSmith for hinting the problem. I was looking into it after reading your comment. I made two changes to the code and it worked:

  1. As pointed by you, I realised that the components MarkdownEditor and MarkdownPreviewer were not getting data as props from Redux. I didn’t connect them properly with Redux. So, I updated the code as:
const MarkdownEditor = ReactRedux.connect(mapStateToProps, {


const MarkdownPreviewer = ReactRedux.connect(mapStateToPropss, {
  1. Since marked was not getting identified as a function in the code, I added an import statement as:
import marked from "";

My code is working now. It would be great if you could have a review. Thanks a lot for your help!!


1 Like

I’d be happy to look at the finished project. Create a thread to review it and tag me in it.


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.