Skip to content

Commit b5e1bb2

Browse files
React.Component synctax change fix
React.Component({}) syntax has changed to React.Component<{}> At least for rescript 9.12
1 parent 1e336f0 commit b5e1bb2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pages/docs/react/latest/beyond-jsx.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ JSX is a syntax sugar that allows us to use React components in an HTML like man
1818
1919
## Component Types
2020

21-
A plain React component is defined as a `('props) => React.element` function. You can also express a component more efficiently with our shorthand type `React.component('props)`.
21+
A plain React component is defined as a `('props) => React.element` function. You can also express a component more efficiently with our shorthand type `React.component<'props>`.
2222

2323
Here are some examples on how to define your own component types (often useful when interoping with existing JS code, or passing around components):
2424

@@ -30,10 +30,10 @@ type friendComp =
3030
// Equivalent to
3131
// ({"padding": string, "children": React.element}) => React.element
3232
type containerComp =
33-
React.component({
33+
React.component<{
3434
"padding": string,
3535
"children": React.element
36-
});
36+
}>;
3737
```
3838
The types above are pretty low level (basically the JS representation of a React component), but since ReScript React has its own ways of defining React components in a more language specific way, let's have a closer look on the anatomy of such a construct.
3939

0 commit comments

Comments
 (0)