Это может быть связано с блокировщиком рекламы. Если вы используете один из них,
добавьте адрес reactjs.org в белый список, чтобы примеры кода заработали.
);
} else if (error != null) {
errorMessage = error.message;
}
return (
Интерактивный JSX-редактор
{error && (
Ошибка
{errorMessage}
)}
{!error && (
Результат
)}
);
}
_render() {
const {compiled} = this.state;
try {
// Example code requires React, ReactDOM, and Remarkable to be within scope.
// It also requires a "mountNode" variable for ReactDOM.render()
// eslint-disable-next-line no-new-func
new Function('React', 'ReactDOM', 'Remarkable', compiled)(
React,
ReactDOM,
Remarkable,
);
} catch (error) {
console.error(error);
this.setState({
compiled: null,
error,
});
}
}
_updateState(code, showJSX = true) {
try {
let newState = {
compiled: compileES5(code),
error: null,
};
if (showJSX) {
newState.code = code;
newState.compiledES6 = compileES6(code);
} else {
newState.compiledES6 = code;
}
return newState;
} catch (error) {
console.error(error);
// Certain ad blockers (eg Fair AdBlocker) prevent Babel from loading.
// If we suspect this is the case, we can show a more helpful error.
const showBabelErrorMessage = !window.Babel;
return {
compiled: null,
error,
showBabelErrorMessage,
};
}
}
_onChange = code => {
this.setState(state => this._updateState(code, state.showJSX));
};
}
export default CodeEditor;