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
Copy file name to clipboardExpand all lines: misc_docs/syntax/decorator_react_component.mdx
+12-9Lines changed: 12 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,13 @@ summary: "This is the `@react.component` decorator."
6
6
category: "decorators"
7
7
---
8
8
9
-
The `@react.component` decorator is used to annotate functions that are [ReasonReact](https://reasonml.github.io/reason-react/en/) components.
9
+
The `@react.component` decorator is used to annotate functions that are [React](/docs/react/latest/elements-and-jsx) components.
10
10
11
11
You will need this decorator whenever you want to use a ReScript / React component in ReScript JSX expressions.
12
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.
13
+
14
+
> **Note**
15
+
> The `@react.component` decorator requires the [react-jsx or jsx config](/docs/react/latest/installation) to be set in your `bsconfig.json` to enable the required React transformations.
14
16
15
17
### Example
16
18
@@ -19,23 +21,24 @@ You will need this decorator whenever you want to use a ReScript / React compone
19
21
```res
20
22
@react.component
21
23
let make = (~name) => {
22
-
<button> {ReasonReact.string("Hello " ++ name ++ "!")} </button>
24
+
<button> {React.string("Hello " ++ name ++ "!")} </button>
23
25
}
24
26
```
25
27
26
28
```js
27
-
var React =require("react");
29
+
import*asJsxRuntimefrom"react/jsx-runtime";
28
30
29
-
functionMyComponent(Props) {
30
-
var name =Props.name;
31
-
returnReact.createElement("button", undefined, "Hello "+ name +"!");
0 commit comments