質問編集履歴
3
一時的に削除します。。。
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,122 +2,4 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
```ここに言語を入力
|
8
|
-
|
9
|
-
WrappedComponent => wrappedComponentProps => {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
```
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# 元のコード
|
18
|
-
|
19
|
-
[http://redux.js.org/docs/recipes/UsingImmutableJS.html](http://redux.js.org/docs/recipes/UsingImmutableJS.html)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
```JavaScript
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
import React from 'react'
|
28
|
-
|
29
|
-
import { Iterable } from 'immutable'
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
export const toJS = WrappedComponent => wrappedComponentProps => {
|
34
|
-
|
35
|
-
const KEY = 0
|
36
|
-
|
37
|
-
const VALUE = 1
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
const propsJS = Object.entries(
|
42
|
-
|
43
|
-
wrappedComponentProps
|
44
|
-
|
45
|
-
).reduce((newProps, wrappedComponentProp) => {
|
46
|
-
|
47
|
-
newProps[wrappedComponentProp[KEY]] = Iterable.isIterable(
|
48
|
-
|
49
|
-
wrappedComponentProp[VALUE]
|
50
|
-
|
51
|
-
)
|
52
|
-
|
53
|
-
? wrappedComponentProp[VALUE].toJS()
|
54
|
-
|
55
|
-
: wrappedComponentProp[VALUE]
|
56
|
-
|
57
|
-
return newProps
|
58
|
-
|
59
|
-
}, {})
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
return <WrappedComponent {...propsJS} />
|
64
|
-
|
65
|
-
}
|
66
|
-
|
67
|
-
```
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
5
|
+
一時的に削除します。。。
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
```JavaScript
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
import React from 'react'
|
80
|
-
|
81
|
-
import { Iterable } from 'immutable'
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
export const toJS = function(WrappedComponent){
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
return function(wrappedComponentProps) {
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
const KEY = 0
|
94
|
-
|
95
|
-
const VALUE = 1
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
const listOfKeyValuePairs = Object.entries(wrappedComponentProp);
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
const propsJS = listOfKeyValuePair.reduce(function(newProps, wrappedComponentProp){
|
104
|
-
|
105
|
-
const isIterable = Iterable.isIterable(wrappedComponentProp[VALUE]);
|
106
|
-
|
107
|
-
newProps[wrappedComponentProp[KEY]] = isIterable === true ? wrappedComponentProp[VALUE].toJS() : wrappedComponentProp[VALUE];
|
108
|
-
|
109
|
-
return newProps;
|
110
|
-
|
111
|
-
}, {});
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
return <WrappedComponent {...propsJS} />
|
116
|
-
|
117
|
-
}
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
}
|
122
|
-
|
123
|
-
```
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,6 +21,14 @@
|
|
21
21
|
|
22
22
|
|
23
23
|
```JavaScript
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
import React from 'react'
|
28
|
+
|
29
|
+
import { Iterable } from 'immutable'
|
30
|
+
|
31
|
+
|
24
32
|
|
25
33
|
export const toJS = WrappedComponent => wrappedComponentProps => {
|
26
34
|
|
@@ -66,6 +74,14 @@
|
|
66
74
|
|
67
75
|
```JavaScript
|
68
76
|
|
77
|
+
|
78
|
+
|
79
|
+
import React from 'react'
|
80
|
+
|
81
|
+
import { Iterable } from 'immutable'
|
82
|
+
|
83
|
+
|
84
|
+
|
69
85
|
export const toJS = function(WrappedComponent){
|
70
86
|
|
71
87
|
|
1
} }
test
CHANGED
File without changes
|
test
CHANGED
@@ -98,12 +98,10 @@
|
|
98
98
|
|
99
99
|
return <WrappedComponent {...propsJS} />
|
100
100
|
|
101
|
-
```
|
102
|
-
|
103
|
-
|
104
|
-
|
105
101
|
}
|
106
102
|
|
107
103
|
|
108
104
|
|
109
105
|
}
|
106
|
+
|
107
|
+
```
|