I’m having an odd issue with my Markdown Previewer. I have a line of code that should remove HTML from the input. It works fine on my local test environment, but the deployed version does not remove the HTML. I have included the code for the component below. Am I missing something here? The line that should remove the HTML is textInput = textInput.replace(/(<([^>]+)>)/ig,"");
import React, { Component } from 'react';
class MarkdownInput extends Component {
constructor(props) {
super(props);
this.state = {
textInput: ''
}
}
render() {
return (
<div className="col-md-6">
Input
<textarea
value={this.state.textInput}
onChange={event => this.handleChange(event.target.value)} />
</div>
);
};
handleChange(textInput) {
textInput = textInput.replace(/(<([^>]+)>)/ig,"");
this.setState({textInput});
if(this.props.onChange) {
this.props.onChange(textInput);
}
}
}
export default MarkdownInput;
In my test environment, as soon as the closing > is inputed the HTML is stripped out from the input area. In the live version, it is left in and processed by the preview component.