Problems with Markdown Previewer

Problems with Markdown Previewer
0

#1

Hi, I’m having some problems with the Markdown Previewer, here is the link:

The updatePreview method is not doing anything, what am I doing wrong with onChange?

updatePreview = (event) => {
    alert(event)
  }

<Editor value={this.state.previewText} onChange={(event) => this.updatePreview(event.target.value)} />

Thanks.


#2

The onChange event is triggered on the texarea element, not on your custom Editor component^^

<textarea id="editor" onChange={this.props.onChange}>

Adding this will make that works ^^

Tip
You can avoid to manually pass the event:

onChange={this.updatePreview()}

This should works aswell :slight_smile:


#3

That fixed it, thank you!!

I saw that it was passing the onChange prop but I thought that’s all I needed to do.