Skip to content

Commit de711ef

Browse files
committed
When proxying statics functions, copy properties
Port of 0760470 which went in externally before ReactLegacyDescriptor happened, so it needed to be ported.
1 parent 23c5332 commit de711ef

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/core/ReactLegacyDescriptor.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ function proxyStaticMethods(target, source) {
3434
if (source.hasOwnProperty(key)) {
3535
var value = source[key];
3636
if (typeof value === 'function') {
37-
target[key] = value.bind(source);
37+
var bound = value.bind(source);
38+
// Copy any properties defined on the function, such as `isRequired` on
39+
// a PropTypes validator. (mergeInto refuses to work on functions.)
40+
for (var k in value) {
41+
if (value.hasOwnProperty(k)) {
42+
bound[k] = value[k];
43+
}
44+
}
45+
target[key] = bound;
3846
} else {
3947
target[key] = value;
4048
}

0 commit comments

Comments
 (0)