Skip to content

Commit 90225a6

Browse files
committed
Add Syntax Lookup @react.component decorator
1 parent f3262dd commit 90225a6

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
id: "react-component-decorator"
3+
keywords: ["react", "component", "decorator"]
4+
name: "@react.component"
5+
summary: "This is the `@react.component` decorator."
6+
category: "decorators"
7+
---
8+
9+
The `@react.component` decorator is used to annotate functions that are [ReasonReact](https://reasonml.github.io/reason-react/en/) components.
10+
11+
### Example
12+
13+
<CodeTab labels={["ReScript", "JS Output"]}>
14+
15+
```res
16+
@react.component
17+
let make = (~name) => {
18+
<button> {ReasonReact.string("Hello " ++ name ++ "!")} </button>
19+
}
20+
```
21+
22+
```js
23+
var React = require("react");
24+
25+
function MyComponent(Props) {
26+
var name = Props.name;
27+
return React.createElement("button", undefined, "Hello " + name + "!");
28+
}
29+
30+
var make = MyComponent;
31+
```
32+
33+
</CodeTab>
34+
35+
### References
36+
37+
* [ReasonReact Components](https://reasonml.github.io/reason-react/docs/en/components)

0 commit comments

Comments
 (0)