Skip to content

Commit 2321dd1

Browse files
aspeddrocristianoc
authored andcommitted
update react.component attr
1 parent b772d16 commit 2321dd1

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

misc_docs/syntax/decorator_react_component.mdx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ summary: "This is the `@react.component` decorator."
66
category: "decorators"
77
---
88

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.
1010

1111
You will need this decorator whenever you want to use a ReScript / React component in ReScript JSX expressions.
1212

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.
1416
1517
### Example
1618

@@ -19,23 +21,24 @@ You will need this decorator whenever you want to use a ReScript / React compone
1921
```res
2022
@react.component
2123
let make = (~name) => {
22-
<button> {ReasonReact.string("Hello " ++ name ++ "!")} </button>
24+
<button> {React.string("Hello " ++ name ++ "!")} </button>
2325
}
2426
```
2527

2628
```js
27-
var React = require("react");
29+
import * as JsxRuntime from "react/jsx-runtime";
2830

29-
function MyComponent(Props) {
30-
var name = Props.name;
31-
return React.createElement("button", undefined, "Hello " + name + "!");
31+
function Playground(props) {
32+
return JsxRuntime.jsx("button", {
33+
children: "Hello " + props.name + "!"
34+
});
3235
}
3336

34-
var make = MyComponent;
37+
var make = Playground;
3538
```
3639

3740
</CodeTab>
3841

3942
### References
4043

41-
* [ReasonReact Components](https://reasonml.github.io/reason-react/docs/en/components)
44+
* [React Components](/docs/react/latest/components-and-props)

0 commit comments

Comments
 (0)