1
- const handledPropsCache = { }
2
-
3
1
/**
4
2
* Push all `source` array elements to the `target` array if they don't already exist in `target`.
5
3
*
@@ -19,9 +17,8 @@ const pushUnique = (source, target) => source.forEach(x => {
19
17
* @returns {{} } A shallow copy of the prop object
20
18
*/
21
19
const getUnhandledProps = ( Component , props ) => {
22
- const { _meta : { name } , autoControlledProps, defaultProps, propTypes } = Component
23
-
24
- let handledProps = handledPropsCache [ name ]
20
+ const { autoControlledProps, defaultProps, propTypes } = Component
21
+ let { handledProps } = Component
25
22
26
23
// ----------------------------------------
27
24
// Calculate handledProps once and cache
@@ -33,9 +30,12 @@ const getUnhandledProps = (Component, props) => {
33
30
if ( defaultProps ) pushUnique ( Object . keys ( defaultProps ) , handledProps )
34
31
if ( propTypes ) pushUnique ( Object . keys ( propTypes ) , handledProps )
35
32
36
- handledPropsCache [ name ] = handledProps
33
+ Component . handledProps = handledProps
37
34
}
38
35
36
+ // ----------------------------------------
37
+ // Return _unhandled_ props
38
+ // ----------------------------------------
39
39
return Object . keys ( props ) . reduce ( ( acc , prop ) => {
40
40
if ( handledProps . indexOf ( prop ) === - 1 ) acc [ prop ] = props [ prop ]
41
41
return acc
0 commit comments