-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathReactMeteor.js
More file actions
38 lines (31 loc) · 889 Bytes
/
ReactMeteor.js
File metadata and controls
38 lines (31 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var ReactMeteorMixin = {
_handleMeteorChange: function () {
if (this.getMeteorState !== undefined) {
this.setState(this.getMeteorState())
}
},
_cancelComputation: function () {
if (this._meteorComputation) {
this._meteorComputation.stop()
this._meteorComputation = null
}
},
componentWillMount: function () {
this._meteorComputation = Tracker.autorun(this._handleMeteorChange)
},
componentWillReceiveProps: function (nextProps) {
var oldProps = this.props
this.props = nextProps
this._handleMeteorChange()
this.props = oldProps
},
componentWillUnmount: function () {
this._cancelComputation()
}
}
if (typeof exports === "object") {
ReactMeteor = exports
} else {
ReactMeteor = {}
}
ReactMeteor.Mixin = ReactMeteorMixin