Skip to content

Commit 729d3fe

Browse files
committed
Update tsx.md
1 parent 22d55f9 commit 729d3fe

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/jsx/tsx.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,31 @@ TypeScript provides you with the ability to use something other than React with
6464
* When using components:
6565
* You can control which `class` must be inherited by components by customizing the default `interface ElementClass extends React.Component<any, any> { }` declaration.
6666
* You can control which property is used to type check the attributes (the default is `props`) by customizing the `declare module JSX { interface ElementAttributesProperty { props: {}; } }` declaration.
67+
68+
## `reactNamespace`
69+
70+
Passing `--reactNamespace <JSX factory Name>` along with `--jsx react` allows for using a different JSX factory from the default `React`.
71+
72+
The new factory name will be used to call `createElement` functions.
73+
74+
##### Example
75+
76+
```ts
77+
import {jsxFactory} from "jsxFactory";
78+
79+
var div = <div>Hello JSX!</div>
80+
```
81+
82+
Compiled with:
83+
84+
```shell
85+
tsc --jsx react --reactNamespace jsxFactory --m commonJS
86+
```
87+
88+
Results in:
89+
90+
```js
91+
"use strict";
92+
var jsxFactory_1 = require("jsxFactory");
93+
var div = jsxFactory_1.jsxFactory.createElement("div", null, "Hello JSX!");
94+
```

0 commit comments

Comments
 (0)