Babel plugin that automatically adds displayName properties to React class components created with createClass
Overall
score
96%
A transformer that injects displayName into React class component definitions by deriving names from surrounding assignments, object properties, and member expressions even when the creation call is wrapped inside other expressions.
createClass call is the value of an object property and the object is assigned, the property key becomes the injected displayName if one is missing. @testcreateClass call is assigned to a member expression such as registry.Widget, the right-most property name becomes the injected displayName if absent. @testcreateClass call is wrapped inside another call on the right-hand side of an assignment (e.g., const Banner = wrap(createClass(...))), the left-hand identifier becomes the injected displayName. @testdisplayName already exists inside the object literal, it is preserved and not overwritten, even in nested scenarios. @test@generates
/**
* Transforms source code so React class component factories gain a displayName derived
* from nearby assignment or property context while preserving existing displayName entries.
*
* @param source JavaScript or TypeScript module source containing createClass calls.
* @returns The transformed source code with injected displayName fields where applicable.
*/
export function transformWithDisplayNames(source: string): string;Transforms createClass calls to inject displayName, including when nested in member expressions or wrapped calls.
@satisfied-by
Provides the compiler pipeline required to run the display name transform. @satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-babel-plugin-transform-react-display-name