Better implementation
This commit is contained in:
parent
c928fbccaf
commit
04c9780ee1
@ -51,13 +51,20 @@ function renderToken(token, index = 0, key = '0') {
|
|||||||
|
|
||||||
export default class MarkitupReactRenderer extends React.Component {
|
export default class MarkitupReactRenderer extends React.Component {
|
||||||
|
|
||||||
render() {
|
constructor(props) {
|
||||||
const { value, syntax } = this.props;
|
super(props);
|
||||||
|
const { syntax } = props;
|
||||||
|
this.parser = new MarkupIt(syntax);
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof this.parser === 'undefined') {
|
componentWillReceiveProps(nextProps) {
|
||||||
this.parser = new MarkupIt(syntax);
|
if (nextProps.syntax != this.props.syntax) {
|
||||||
|
this.parser = new MarkupIt(nextProps.syntax);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { value } = this.props;
|
||||||
const content = this.parser.toContent(value);
|
const content = this.parser.toContent(value);
|
||||||
const json = JSONUtils.encode(content);
|
const json = JSONUtils.encode(content);
|
||||||
// console.log(JSON.stringify(json, null, 2));
|
// console.log(JSON.stringify(json, null, 2));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user