File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -94,11 +94,14 @@ function getDefaultValuesFromProps(
94
94
// Don't evaluate property if component is functional and the node is not an AssignmentPattern
95
95
. filter ( propertyPath => ! isStatelessComponent || types . AssignmentPattern . check ( propertyPath . get ( 'value' ) . node ) )
96
96
. forEach ( function ( propertyPath ) {
97
- var propDescriptor = documentation . getPropDescriptor (
97
+ const propDescriptor = documentation . getPropDescriptor (
98
98
getPropertyName ( propertyPath )
99
99
) ;
100
- var value = isStatelessComponent ? propertyPath . get ( 'value' , 'right' ) : propertyPath . get ( 'value' ) ;
101
- var defaultValue = getDefaultValue ( value , isStatelessComponent ) ;
100
+ const defaultValue = getDefaultValue (
101
+ isStatelessComponent ?
102
+ propertyPath . get ( 'value' , 'right' ) :
103
+ propertyPath . get ( 'value' )
104
+ ) ;
102
105
if ( defaultValue ) {
103
106
propDescriptor . defaultValue = defaultValue ;
104
107
}
Original file line number Diff line number Diff line change @@ -121,14 +121,17 @@ export default function resolveToValue(path: NodePath): NodePath {
121
121
} else if ( types . MemberExpression . check ( node ) ) {
122
122
const resolved = resolveToValue ( getMemberExpressionRoot ( path ) ) ;
123
123
if ( types . ObjectExpression . check ( resolved . node ) ) {
124
- const memberParts = toArray ( path ) . slice ( 1 ) ;
125
- const init = memberParts . reduce ( ( propertyPath , propertyName ) => {
124
+ let propertyPath = resolved ;
125
+ for ( const propertyName of toArray ( path ) . slice ( 1 ) ) {
126
+ if ( propertyPath && types . ObjectExpression . check ( propertyPath . node ) ) {
127
+ propertyPath = getPropertyValuePath ( propertyPath , propertyName ) ;
128
+ }
129
+ if ( ! propertyPath ) {
130
+ return path ;
131
+ }
126
132
propertyPath = resolveToValue ( propertyPath ) ;
127
- return types . ObjectExpression . check ( propertyPath . node ) ?
128
- getPropertyValuePath ( propertyPath , propertyName ) :
129
- null ;
130
- } , resolved ) ;
131
- return init ? resolveToValue ( init ) : path ;
133
+ }
134
+ return propertyPath ;
132
135
}
133
136
} else if (
134
137
types . ImportDefaultSpecifier . check ( node ) ||
You can’t perform that action at this time.
0 commit comments