Skip to content

Commit

Permalink
Allow component names to start with _
Browse files Browse the repository at this point in the history
Fixes #424
  • Loading branch information
yang committed Feb 28, 2019
1 parent d94e66f commit 0bac644
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/transformers/JSXTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export default class JSXTransformer extends Transformer {
}

export function startsWithLowerCase(s: string): boolean {
return s[0] === s[0].toLowerCase();
return s[0] !== s[0].toUpperCase();
}

/**
Expand Down
11 changes: 11 additions & 0 deletions test/jsx-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ describe("transform JSX", () => {
);
});

it("handles component names starting with _", () => {
assertResult(
`
<_Foo />
`,
`${JSX_PREFIX}
React.createElement(_Foo, {${devProps(2)}} )
`,
);
});

it("transforms nested JSX elements", () => {
assertResult(
`
Expand Down

0 comments on commit 0bac644

Please sign in to comment.