Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-component-tree",
"version": "0.2.1",
"version": "0.2.2",
"description": "Serialize and reproduce the state of an entire tree of React components",
"main": "build/bundle.js",
"repository": {
Expand Down
18 changes: 9 additions & 9 deletions src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ exports.injectState = function(component, state) {
var rootState = _.omit(state, 'children'),
childrenStates = state.children;

component.setState(rootState);

if (_.isEmpty(childrenStates)) {
return;
}

_.each(component.refs, function(child, ref) {
if (!_.isEmpty(childrenStates[ref])) {
exports.injectState(child, childrenStates[ref]);
component.setState(rootState, function() {
if (_.isEmpty(childrenStates)) {
return;
}

_.each(component.refs, function(child, ref) {
if (!_.isEmpty(childrenStates[ref])) {
exports.injectState(child, childrenStates[ref]);
}
});
});
};