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

Function addDisplayName

transforms/class.js:1121–1136  ·  view source on GitHub ↗
(displayName, specPath)

Source from the content-addressed store, hash-verified

1119 };
1120
1121 const addDisplayName = (displayName, specPath) => {
1122 const props = specPath.properties;
1123 let safe = true;
1124
1125 for (let i = 0; i < props.length; i++) {
1126 const prop = props[i];
1127 if (prop.key.name === 'displayName') {
1128 safe = false;
1129 break;
1130 }
1131 }
1132
1133 if (safe) {
1134 props.unshift(j.objectProperty(j.identifier('displayName'), j.stringLiteral(displayName)));
1135 }
1136 };
1137
1138 const fallbackToCreateClassModule = (classPath) => {
1139 const comments = getComments(classPath);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected