"README.md" did not exist on "49571dab67bcfa9145cc1b9369b50f2373ba0af4"
Newer
Older
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React from 'react'
class AppController {
constructor() {
this.LastObjectModificationsContext = React.createContext()
}
init(context) {
this.context = context
const initialState = {
lastObjectModifications: 'abc'
}
context.initState(initialState)
}
getLastObjectModifications() {
return this.context.getState().lastObjectModifications
}
setLastObjectModifications(lastObjectModifications) {
this.context.setState({
lastObjectModifications: lastObjectModifications
})
}
withLastObjectModifications() {
return this._withContext(
this.LastObjectModificationsContext,
'lastObjectModifications'
)
}
_withContext(Context, propertyName) {
const WithContext = Component => {
const WithConsumer = props => {
return React.createElement(Context.Consumer, {}, value =>
React.createElement(Component, {
...props,
[propertyName]: value
})
)
}
WithConsumer.displayName = 'WithConsumer'
return WithConsumer
}
WithContext.displayName = 'WithContext'
return WithContext
}
}
export default new AppController()