Projekt

Obecné

Profil

Stáhnout (819 Bajtů) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
# babel-plugin-transform-react-display-name
2
3
> Add displayName to `createReactClass` (and `React.createClass`) calls
4
5
## Example
6
7
**In**
8
9
```js
10
var foo = React.createClass({}); // React <= 15
11
var bar = createReactClass({});  // React 16+
12
```
13
14
**Out**
15
16
```js
17
var foo = React.createClass({
18
  displayName: "foo"
19
}); // React <= 15
20
var bar = createReactClass({
21
  displayName: "bar"
22
}); // React 16+
23
```
24
25
## Installation
26
27
```sh
28
npm install --save-dev babel-plugin-transform-react-display-name
29
```
30
31
## Usage
32
33
### Via `.babelrc` (Recommended)
34
35
**.babelrc**
36
37
```json
38
{
39
  "plugins": ["transform-react-display-name"]
40
}
41
```
42
43
### Via CLI
44
45
```sh
46
babel --plugins transform-react-display-name script.js
47
```
48
49
### Via Node API
50
51
```javascript
52
require("babel-core").transform("code", {
53
  plugins: ["transform-react-display-name"]
54
});
55
```