Babel plugin that automatically adds displayName properties to React class components created with createClass
Overall
score
96%
Create a small transform helper that processes JavaScript/TypeScript source strings containing React.createClass or createReactClass calls, injecting component displayName values only when the call receives exactly one object-literal argument.
const Widget = React.createClass({ render() { return null; } });, return code where the object literal starts with displayName: "Widget" while preserving the rest of the class definition. @testReact.createClass({}, {})), throw an error stating that the call must receive a single object-literal argument and include the filename in the message. @testcreateReactClass(factoryFn())), throw an error explaining that the call must wrap a direct object literal. @testdisplayName, return code unchanged except for any formatting performed by the transform. @test@generates
export function transformCreateClass(sourceCode: string, filename?: string): string;Adds displayName support to createClass definitions and validates the argument shape.
Install with Tessl CLI
npx tessl i tessl/npm-babel-plugin-transform-react-display-name