Problems with Markdown Previewer

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.

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:

2 Likes

That fixed it, thank you!!

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

1 Like