MCPcopy Index your code
hub / github.com/plotly/dash / getDefaultProps

Function getDefaultProps

dash/extract-meta.js:419–456  ·  view source on GitHub ↗
(symbol, source)

Source from the content-addressed store, hash-verified

417 };
418
419 const getDefaultProps = (symbol, source) => {
420 const statements = source.statements.filter(
421 stmt =>
422 (!!stmt.name &&
423 checker.getSymbolAtLocation(stmt.name) === symbol) ||
424 ts.isExpressionStatement(stmt) ||
425 ts.isVariableStatement(stmt)
426 );
427 return statements.reduce((acc, statement) => {
428 let propMap = {};
429
430 statement.getChildren().forEach(child => {
431 let {right} = child;
432 if (right && ts.isIdentifier(right)) {
433 const value = source.locals.get(right.escapedText);
434 if (
435 value &&
436 value.valueDeclaration &&
437 ts.isVariableDeclaration(value.valueDeclaration) &&
438 value.valueDeclaration.initializer
439 ) {
440 right = value.valueDeclaration.initializer;
441 }
442 }
443 if (right) {
444 const {properties} = right;
445 if (properties) {
446 propMap = getDefaultPropsValues(properties);
447 }
448 }
449 });
450
451 return {
452 ...acc,
453 ...propMap
454 };
455 }, {});
456 };
457
458 const getPropComment = symbol => {
459 // Doesn't work too good with the JsDocTags losing indentation.

Callers 1

gatherComponentsFunction · 0.85

Calls 5

getDefaultPropsValuesFunction · 0.85
filterMethod · 0.80
reduceMethod · 0.80
getChildrenMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…