2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-06-20 20:00:33 +03:00

fix(react): remove jsx

This commit is contained in:
Nikolay Kostyurin
2018-08-09 11:14:46 +02:00
parent 4ebc512732
commit ada2c0067e
+11 -23
View File
@@ -3,34 +3,22 @@ const PropTypes = require('prop-types');
const core = require('@bbob/core'); const core = require('@bbob/core');
const render = require('./render'); const render = require('./render');
class Component extends React.Component { const toAST = (source, plugins) => core(plugins).process(source).tree;
content() {
return React.Children.map(this.props.children, (child) => {
if (typeof child === 'string') {
// eslint-disable-next-line react/no-danger
return render(this.renderBBCodeToAST(child));
}
return child;
});
}
renderBBCodeToAST(source) { const content = (children, plugins) => React.Children.map(children, child =>
return core(this.props.plugins).process(source).tree; (typeof child === 'string' ? render(toAST(child, plugins)) : child));
}
render() { const Component = props =>
const Container = this.props.container; React.createElement(props.container, {}, content(props.children, props.plugins));
return (<Container>{this.content()}</Container>); if (process.env.NODE_ENV !== 'production') {
} Component.propTypes = {
container: PropTypes.node,
children: PropTypes.node.isRequired,
plugins: PropTypes.arrayOf(Function),
};
} }
Component.propTypes = {
container: PropTypes.node,
children: PropTypes.node.isRequired,
plugins: PropTypes.arrayOf(Function),
};
Component.defaultProps = { Component.defaultProps = {
container: 'span', container: 'span',
plugins: [], plugins: [],