Skip to content

Commit

Permalink
Moves state rehydrating deleting to componentWillMount to avoid issue…
Browse files Browse the repository at this point in the history
…s with interop with other libs using react-async-bootstrapper.
  • Loading branch information
ctrlplusb committed Apr 5, 2017
1 parent fb69a7b commit 3e5a346
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/JobProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class JobProvider extends Component {
register: PropTypes.func.isRequired,
get: PropTypes.func.isRequired,
getRehydrate: React.PropTypes.func.isRequired,
removeRehydrate: React.PropTypes.func.isRequired,
}).isRequired,
};

Expand All @@ -48,6 +49,9 @@ class JobProvider extends Component {
delete this.rehydrateState.jobs[id]
return rehydration
},
removeRehydrate: (id) => {
delete this.rehydrateState.jobs[id]
},
},
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/withJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ export default function withJob(config) {
register: PropTypes.func.isRequired,
get: PropTypes.func.isRequired,
getRehydrate: React.PropTypes.func.isRequired,
removeRehydrate: React.PropTypes.func.isRequired,
}),
}
};

constructor(props, context) {
super(props, context)
Expand All @@ -58,9 +59,7 @@ export default function withJob(config) {
}

// node
return serverMode === 'defer'
? false
: this.resolveWork(this.props)
return serverMode === 'defer' ? false : this.resolveWork(this.props)
}

componentWillMount() {
Expand All @@ -83,6 +82,10 @@ export default function withJob(config) {
if (!this.state.completed) {
this.resolveWork(this.props)
}

if (this.context.jobs && env === 'browser') {
this.context.jobs.removeRehydrate(id)
}
}

componentWillUnmount() {
Expand Down

0 comments on commit 3e5a346

Please sign in to comment.