Pachu Pachu - 4 months ago 20
React JSX Question

React - adding class to children components

im using react and I have a component that simply needs to render the children and add them a class according to a condition.
Whats the best way of doing it?


I figured it out a week ago, this is what I wanted :

export default class ContainerComponent extends React.Component {
    constructor(props) {

        this.modifyChildren = this.modifyChildren.bind(this);

    modifyChildren(child) {
        const className = classNames(

        const props = {

        return React.cloneElement(child, props);
    render() {
        return (<div>
            {, this.modifyChildren(child))}