-
Notifications
You must be signed in to change notification settings - Fork 49.8k
Closed
Description
This comes from my discussion with several people around animation, but I feel like it's important enough to warrant its own issue.
We already insist that render should be a pure function of this.props and this.state. How about taking this further and pass those in CompositeComponent? This way we can write:
render: function(props, state) {
return <div>{props.something}</div>;
}While most of the time we'll still call render(this.props, this.state) internally, with this we will be able to do render(somePrevProps, someTestState) from React or even from the user. Being able to "test the water" would be very valuable in the future. For example:
componentWillReceiveProps: function(nextProps) {
var result1 = this.render(this.props, this.state);
var result2 = this.render(nextProps, this.state);
// Collection of changed stuff. Good for preparing mounting/unmounting animations or such logic.
React.reconciler.getDiff(result1, result2);
this.setState({...});
}I've heard this can also solve some problems with pendingState? Not too familiar with the issue.
@jordwalke @sebmarkbage @petehunt
denis-sokolov, nippur72, wmertens, gunn, ianstormtaylor and 27 more