I'm using react-router, and I need to pass props to handler Comments
component (look at the code below). It's usually solved by creating a wrapper component.
BUT Comments
is already a es6 wrapper of AbstractComments
, so I don't want to create one more wrapper. So I do it in the next way:
Problem/Question: look please at Comments#onChange
method
Comments component
// Where AbstractComment extends React.Component
class Comments extends AbstractComments {
constructor(props) {
//Pass my custom props to component
super(_.assign(props, {
chatName: '....',
title: '...',
comments: '.....'
}));
}
_onChange() {
//PROBLEM: after setState Comments component get rendered
//without my custom props: (chatName, title, comments)
//QUESTION: how to re-render it with the same properties?
this.setState(someNewState);
}
}
How Comments
is rendered by react-router:
var Index = React.createClass({
render: function () {
return (
<div>
<header>Some header</header>
<RouteHandler />
</div>
);
}
});
var routes = (
<Route path="/" handler={Index}>
<Route path="comments" handler={Comments}/>
<DefaultRoute handler={Dashboard}/>
</Route>
);
ReactRouter.run(routes, function (Handler) {
React.render(<Handler/>, document.body);
});