Skip to content

Commit 3e5a346

Browse files
committed
Moves state rehydrating deleting to componentWillMount to avoid issues with interop with other libs using react-async-bootstrapper.
1 parent fb69a7b commit 3e5a346

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/JobProvider.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class JobProvider extends Component {
2929
register: PropTypes.func.isRequired,
3030
get: PropTypes.func.isRequired,
3131
getRehydrate: React.PropTypes.func.isRequired,
32+
removeRehydrate: React.PropTypes.func.isRequired,
3233
}).isRequired,
3334
};
3435

@@ -48,6 +49,9 @@ class JobProvider extends Component {
4849
delete this.rehydrateState.jobs[id]
4950
return rehydration
5051
},
52+
removeRehydrate: (id) => {
53+
delete this.rehydrateState.jobs[id]
54+
},
5155
},
5256
}
5357
}

src/withJob.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ export default function withJob(config) {
3939
register: PropTypes.func.isRequired,
4040
get: PropTypes.func.isRequired,
4141
getRehydrate: React.PropTypes.func.isRequired,
42+
removeRehydrate: React.PropTypes.func.isRequired,
4243
}),
43-
}
44+
};
4445

4546
constructor(props, context) {
4647
super(props, context)
@@ -58,9 +59,7 @@ export default function withJob(config) {
5859
}
5960

6061
// node
61-
return serverMode === 'defer'
62-
? false
63-
: this.resolveWork(this.props)
62+
return serverMode === 'defer' ? false : this.resolveWork(this.props)
6463
}
6564

6665
componentWillMount() {
@@ -83,6 +82,10 @@ export default function withJob(config) {
8382
if (!this.state.completed) {
8483
this.resolveWork(this.props)
8584
}
85+
86+
if (this.context.jobs && env === 'browser') {
87+
this.context.jobs.removeRehydrate(id)
88+
}
8689
}
8790

8891
componentWillUnmount() {

0 commit comments

Comments
 (0)