You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
+
You will need this decorator whenever you want to use a ReScript / React component in ReScript JSX expressions.
12
+
13
+
**Note:** The `@react.component` decorator requires the [react-jsx config](/docs/manual/latest/build-configuration#reason-refmt-old) to be set in your `bsconfig.json` to enable the required React transformations.
14
+
15
+
### Example
16
+
17
+
<CodeTablabels={["ReScript", "JS Output"]}>
18
+
19
+
```res
20
+
@react.component
21
+
let make = (~name) => {
22
+
<button> {ReasonReact.string("Hello " ++ name ++ "!")} </button>
23
+
}
24
+
```
25
+
26
+
```js
27
+
var React =require("react");
28
+
29
+
functionMyComponent(Props) {
30
+
var name =Props.name;
31
+
returnReact.createElement("button", undefined, "Hello "+ name +"!");
0 commit comments