Markdown Previewer marked module

Could someone tell me what am I doing wrong?

import React, { Component } from 'react';
import marked from 'marked';
import './App.css';

class App extends Component {

  constructor(props) {
    this.takeInput = this.takeInput.bind(this);
    this.state = {
      text: ''

  takeInput(event) {

  giveOutput() {
    const output = marked(this.state.text, {sanitize: true});
    return {__html: output};

  render() {
    return (
      <div className="App">
        <header className="header">
          <h1>GitHub Markdown Previewer</h1>
        <div className="wrapper">
          <div className="input">
            <textarea onChange={this.takeInput}/>
          <div className="output" dangerouslySetInnerHTML={this.giveOutput()}/>

export default App;

When I enter input in the textarea I get the exact same output in the output div…

I’ve found this solution on StackOverflow since docs for react-marked on npm are prehistoric, but obviously this doesn’t work either.


Try removing the sanitize option when you call marked.

Tried it. Doesn’t work :frowning:

Ok, I got it, it works now. It was small binding mistake…

1 Like

can you be more specific what was the issue, please?
It seems I am encountering similar obstacles.

Sorry, I can’t remember exactly what was wrong, but the mistake wasn’t in this file, so this code is ok.