(defaultProps, propTypes)
| 42980 | |
| 42981 | |
| 42982 | function addAsyncPropsToPropPrototype(defaultProps, propTypes) { |
| 42983 | var defaultValues = {}; |
| 42984 | var descriptors = { |
| 42985 | // Default "resolved" values for async props, returned if value not yet resolved/set. |
| 42986 | _asyncPropDefaultValues: { |
| 42987 | enumerable: false, |
| 42988 | value: defaultValues |
| 42989 | }, |
| 42990 | // Shadowed object, just to make sure "early indexing" into the instance does not fail |
| 42991 | _asyncPropOriginalValues: { |
| 42992 | enumerable: false, |
| 42993 | value: {} |
| 42994 | } |
| 42995 | }; // Move async props into shadow values |
| 42996 | |
| 42997 | for (var propName in propTypes) { |
| 42998 | var propType = propTypes[propName]; |
| 42999 | var name = propType.name, |
| 43000 | value = propType.value; // Note: async is ES7 keyword, can't destructure |
| 43001 | |
| 43002 | if (propType.async) { |
| 43003 | defaultValues[name] = value; |
| 43004 | descriptors[name] = getDescriptorForAsyncProp(name, value); |
| 43005 | } |
| 43006 | } |
| 43007 | |
| 43008 | Object.defineProperties(defaultProps, descriptors); |
| 43009 | } // Helper: Configures getter and setter for one async prop |
| 43010 | |
| 43011 | |
| 43012 | function getDescriptorForAsyncProp(name) { |
no test coverage detected