MCPcopy Index your code
hub / github.com/reactjs/react-codemod / collectStatics

Function collectStatics

transforms/class.js:393–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391 // simplifies `getDefaultProps` or converts it to an IIFE;
392 // and collects everything else in the `statics` property object.
393 const collectStatics = specPath => {
394 const result = [];
395
396 for (let i = 0; i < specPath.properties.length; i++) {
397 const property = specPath.properties[i];
398 if (createFindPropFn('statics')(property) && property.value && property.value.properties) {
399 result.push(...property.value.properties);
400 } else if (createFindPropFn(DEFAULT_PROPS_FIELD)(property)) {
401 result.push(createDefaultProps(property));
402 } else if (property.key && STATIC_KEYS.hasOwnProperty(property.key.name)) {
403 result.push(property);
404 }
405 }
406
407 return result;
408 };
409
410 const collectNonStaticProperties = specPath => specPath.properties
411 .filter(prop =>

Callers 1

updateToClassFunction · 0.85

Calls 2

createFindPropFnFunction · 0.85
createDefaultPropsFunction · 0.85

Tested by

no test coverage detected