I have a React component that manages several accordions in the list, but when I update the children, the React dev tools show the updated text, but it does not update in the / ui view. Please advice.
var AccordionComponent = React.createClass({ getInitialState: function() { var self = this; var accordions = this.props.children.map(function(accordion, i) { return clone(accordion, { onClick: self.handleClick, key: i }); }); return { accordions: accordions } }, handleClick: function(i) { var accordions = this.state.accordions; accordions = accordions.map(function(accordion) { if (!accordion.props.open && accordion.props.index === i) { accordion.props.open = true; } else { accordion.props.open = false; } return accordion; }); this.setState({ accordions: accordions }); }, componentWillReceiveProps: function(nextProps) { var accordions = this.state.accordions.map(function(accordion, i) { var newProp = nextProps.children[i].props; accordion.props = assign(accordion.props, { title: newProp.title, children: newProp.children }); return accordion; }); this.setState({ accordions: accordions }); }, render: function() { return ( <div> {this.state.accordions} </div> ); }


Edit:
The component raised the componentWillReceiveProps event, but it never gets updated anyway.
thanks
eugene
source share