I'm trying to present the content I inject into an Angular directive within a React component.
See below the call to the component:
<alert type="'danger'">
<strong>Alert</strong>
Voluptatem facilis magnam, optio provident eaque earum.
</alert>
See below my Angular / React component:
const ALERT_TYPES = [
'danger',
'error', // alias for danger
'info',
'primary',
'success',
'warning'
];
angular
.module('app')
.value('Alert', React.createClass({
displayName: 'Alert',
propTypes: {
children: React.PropTypes.node.isRequired,
className: React.PropTypes.string,
type: React.PropTypes.oneOf(ALERT_TYPES).isRequired
},
render() {
var componentClass = classNames(
'Alert',
'Alert--' + this.props.type,
this.props.className
);
return (
<section className={componentClass}>{this.props.children}</section>
);
}
}))
.directive('alert', alert);
function alert(reactDirective) {
return reactDirective('Alert');
}
Unfortunately, this.props.children
returns undefined
. Anyone have any idea how to solve this? Thank you.