Skip to content

Commit aa8d409

Browse files
committed
fix(getUnhandledProps): cache handledProps on Component
1 parent d794aa6 commit aa8d409

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib/getUnhandledProps.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const handledPropsCache = {}
2-
31
/**
42
* Push all `source` array elements to the `target` array if they don't already exist in `target`.
53
*
@@ -19,9 +17,8 @@ const pushUnique = (source, target) => source.forEach(x => {
1917
* @returns {{}} A shallow copy of the prop object
2018
*/
2119
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
2522

2623
// ----------------------------------------
2724
// Calculate handledProps once and cache
@@ -33,9 +30,12 @@ const getUnhandledProps = (Component, props) => {
3330
if (defaultProps) pushUnique(Object.keys(defaultProps), handledProps)
3431
if (propTypes) pushUnique(Object.keys(propTypes), handledProps)
3532

36-
handledPropsCache[name] = handledProps
33+
Component.handledProps = handledProps
3734
}
3835

36+
// ----------------------------------------
37+
// Return _unhandled_ props
38+
// ----------------------------------------
3939
return Object.keys(props).reduce((acc, prop) => {
4040
if (handledProps.indexOf(prop) === -1) acc[prop] = props[prop]
4141
return acc

0 commit comments

Comments
 (0)