);
}
diff --git a/apps/docs/markdown-pages/docs/manual/variant.mdx b/apps/docs/markdown-pages/docs/manual/variant.mdx
index 714914497..22215b69b 100644
--- a/apps/docs/markdown-pages/docs/manual/variant.mdx
+++ b/apps/docs/markdown-pages/docs/manual/variant.mdx
@@ -578,7 +578,7 @@ switch animal {
```javascript
function greetAnimal(animal) {
if (animal !== "Dog" && animal !== "Bird" && animal !== "Cat") {
- return `I don't know how to greet animal ` + animal;
+ return `I don't know how to greet animal ${animal}`;
}
switch (animal) {
case "Dog":
diff --git a/apps/docs/markdown-pages/docs/react/arrays-and-keys.mdx b/apps/docs/markdown-pages/docs/react/arrays-and-keys.mdx
index 600596ae5..ea5bdcbbf 100644
--- a/apps/docs/markdown-pages/docs/react/arrays-and-keys.mdx
+++ b/apps/docs/markdown-pages/docs/react/arrays-and-keys.mdx
@@ -394,7 +394,7 @@ let make = () => {
```
```js
-import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.js";
+import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs";
import * as JsxRuntime from "react/jsx-runtime";
let todos = [
@@ -420,7 +420,7 @@ export { todos, items, make };
```
```jsx
-import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.js";
+import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs";
import * as JsxRuntime from "react/jsx-runtime";
let todos = [
diff --git a/apps/docs/markdown-pages/docs/react/components-and-props.mdx b/apps/docs/markdown-pages/docs/react/components-and-props.mdx
index d4b040548..8703bbbb4 100644
--- a/apps/docs/markdown-pages/docs/react/components-and-props.mdx
+++ b/apps/docs/markdown-pages/docs/react/components-and-props.mdx
@@ -80,7 +80,7 @@ In ReactJS, props are usually described as a single `props` record. In ReScript,
// src/Article.res
@react.component
let make = (~title: string, ~visitorCount: int, ~children: React.element) => {
- let visitorCountMsg = "You are visitor number: " ++ Belt.Int.toString(visitorCount);
+ let visitorCountMsg = "You are visitor number: " ++ Int.toString(visitorCount);
{React.string(title)}
{React.string(visitorCountMsg)}
@@ -93,7 +93,8 @@ let make = (~title: string, ~visitorCount: int, ~children: React.element) => {
import * as JsxRuntime from "react/jsx-runtime";
function Example(props) {
- let visitorCountMsg = "You are visitor number: " + String(props.visitorCount);
+ let visitorCountMsg =
+ "You are visitor number: " + props.visitorCount.toString();
return JsxRuntime.jsxs("div", {
children: [
JsxRuntime.jsx("div", { children: props.title }),
@@ -112,7 +113,8 @@ export { make };
import * as JsxRuntime from "react/jsx-runtime";
function Example(props) {
- let visitorCountMsg = "You are visitor number: " + String(props.visitorCount);
+ let visitorCountMsg =
+ "You are visitor number: " + props.visitorCount.toString();
return (
{props.title}
@@ -201,7 +203,7 @@ let name = Some("Andrea")
```
```js
-import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
+import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs";
import * as JsxRuntime from "react/jsx-runtime";
function Example$Greeting(props) {
@@ -218,7 +220,7 @@ export { Greeting, name };
```
```jsx
-import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
+import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs";
import * as JsxRuntime from "react/jsx-runtime";
function Example$Greeting(props) {
@@ -282,7 +284,7 @@ module MyList = {
```
```js
-import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
+import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs";
import * as JsxRuntime from "react/jsx-runtime";
function Example$Greeting(props) {
@@ -308,7 +310,7 @@ export { Greeting, MyList };
```
```jsx
-import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
+import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs";
import * as JsxRuntime from "react/jsx-runtime";
function Example$Greeting(props) {
@@ -446,7 +448,7 @@ let make = (props: props) => {
```
```js
-import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
+import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs";
import * as JsxRuntime from "react/jsx-runtime";
function Example$Greeting(props) {
@@ -465,7 +467,7 @@ export { Greeting, make };
```
```jsx
-import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
+import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs";
import * as JsxRuntime from "react/jsx-runtime";
function Example$Greeting(props) {
@@ -530,7 +532,7 @@ let make = () => {
```
```js
-import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
+import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs";
import * as JsxRuntime from "react/jsx-runtime";
function Example$Greeting(props) {
@@ -551,7 +553,7 @@ export { Greeting, make };
```
```jsx
-import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
+import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs";
import * as JsxRuntime from "react/jsx-runtime";
function Example$Greeting(props) {
@@ -577,9 +579,9 @@ export { Greeting, make };
**Note:** React components are capitalized; primitive DOM elements like `div` or `button` are uncapitalized. More infos on the JSX specifics and code transformations can be found in our [JSX language manual section](../manual/jsx.mdx#capitalized-tag).
-### Handwritten Components
+### Components with a Props Record
-You don't need to use the `@react.component` decorator to write components that can be used in JSX. Instead you can write the `make` function with type `props` and these will always work as React components. But then you will have the issue with the component name being "make" in the React dev tools.
+Use `@react.componentWithProps` when a component takes a single props record instead of labeled arguments.
For example:
@@ -589,6 +591,7 @@ For example:
module Link = {
type props = {href: string, children: React.element};
+ @react.componentWithProps
let make = (props: props) => {
{props.children}
@@ -600,7 +603,7 @@ module Link = {
```
```js
-import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
+import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs";
import * as JsxRuntime from "react/jsx-runtime";
function Example$Greeting(props) {
@@ -609,19 +612,19 @@ function Example$Greeting(props) {
let Greeting = { make: Example$Greeting };
-function make(props) {
+function Example$Link(props) {
return JsxRuntime.jsx("a", { children: props.children, href: props.href });
}
-let Link = { make: make };
+let Link = { make: Example$Link };
-JsxRuntime.jsx(make, { href: "/docs", children: "Docs" });
+JsxRuntime.jsx(Example$Link, { href: "/docs", children: "Docs" });
export { Greeting, Link };
```
```jsx
-import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
+import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs";
import * as JsxRuntime from "react/jsx-runtime";
function Example$Greeting(props) {
@@ -630,11 +633,11 @@ function Example$Greeting(props) {
let Greeting = { make: Example$Greeting };
-function make(props) {
+function Example$Link(props) {
return {props.children};
}
-let Link = { make: make };
+let Link = { make: Example$Link };
{"Docs"};
diff --git a/apps/docs/markdown-pages/docs/react/elements-and-jsx.mdx b/apps/docs/markdown-pages/docs/react/elements-and-jsx.mdx
index 4bc92f07d..2631716b6 100644
--- a/apps/docs/markdown-pages/docs/react/elements-and-jsx.mdx
+++ b/apps/docs/markdown-pages/docs/react/elements-and-jsx.mdx
@@ -142,7 +142,7 @@ Sometimes it's necessary to pass around component functions to have more control
```res
type props = {name: string}
-let render = (myComp: props => React.element) => {
+let render = (myComp: React.component) => {
{React.createElement(myComp, {name: "Franz"})}
}
```
@@ -164,7 +164,7 @@ There is also a `React.createElementVariadic` function, which takes an array of
```res
type props = {title: string, children: React.element}
-let render = (article: props => React.element) => {
+let render = (article: React.component) => {
let children = [React.string("Introduction"), React.string("Body")]
let props = {title: "Article #1", children: React.null}
diff --git a/apps/docs/markdown-pages/docs/react/extensions-of-props.mdx b/apps/docs/markdown-pages/docs/react/extensions-of-props.mdx
index 10a302a3e..6e64403a5 100644
--- a/apps/docs/markdown-pages/docs/react/extensions-of-props.mdx
+++ b/apps/docs/markdown-pages/docs/react/extensions-of-props.mdx
@@ -42,9 +42,7 @@ let Comp = { make: make };
let props = { b: "b" };
-let newrecord = { ...props };
-
-JsxRuntime.jsx(make, ((newrecord.a = "a"), newrecord));
+JsxRuntime.jsx(make, { ...props, a: "a" });
export { Comp, props };
```
@@ -59,9 +57,7 @@ let Comp = { make: make };
let props = { b: "b" };
-let newrecord = { ...props };
-
-;
+;
export { Comp, props };
```
diff --git a/apps/docs/markdown-pages/docs/react/forwarding-refs.mdx b/apps/docs/markdown-pages/docs/react/forwarding-refs.mdx
index 01c1d7b63..b93d55db6 100644
--- a/apps/docs/markdown-pages/docs/react/forwarding-refs.mdx
+++ b/apps/docs/markdown-pages/docs/react/forwarding-refs.mdx
@@ -125,9 +125,9 @@ let make = () => {
```js
import * as React from "react";
-import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
-import * as Stdlib_Nullable from "@rescript/runtime/lib/es6/Stdlib_Nullable.js";
-import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
+import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs";
+import * as Stdlib_Nullable from "@rescript/runtime/lib/es6/Stdlib_Nullable.mjs";
+import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs";
import * as JsxRuntime from "react/jsx-runtime";
let make = React.forwardRef((props, ref) =>
@@ -174,9 +174,9 @@ export { FancyInput, make$1 as make };
```jsx
import * as React from "react";
-import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
-import * as Stdlib_Nullable from "@rescript/runtime/lib/es6/Stdlib_Nullable.js";
-import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
+import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs";
+import * as Stdlib_Nullable from "@rescript/runtime/lib/es6/Stdlib_Nullable.mjs";
+import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs";
import * as JsxRuntime from "react/jsx-runtime";
let make = React.forwardRef((props, ref) => (
diff --git a/apps/docs/markdown-pages/docs/react/hooks-effect.mdx b/apps/docs/markdown-pages/docs/react/hooks-effect.mdx
index a1ce61677..f749d5369 100644
--- a/apps/docs/markdown-pages/docs/react/hooks-effect.mdx
+++ b/apps/docs/markdown-pages/docs/react/hooks-effect.mdx
@@ -145,7 +145,7 @@ function Example(props) {
let setCount = match[1];
let count = match[0];
React.useEffect(() => {
- document.title = `You clicked ` + count.toString() + ` times!`;
+ document.title = `You clicked ${count.toString()} times!`;
});
let onClick = (_evt) => setCount((prev) => (prev + 1) | 0);
let msg = "You clicked" + count.toString() + "times";
@@ -173,7 +173,7 @@ function Example(props) {
let setCount = match[1];
let count = match[0];
React.useEffect(() => {
- document.title = `You clicked ` + count.toString() + ` times!`;
+ document.title = `You clicked ${count.toString()} times!`;
});
let onClick = (_evt) => setCount((prev) => (prev + 1) | 0);
let msg = "You clicked" + count.toString() + "times";
diff --git a/apps/docs/markdown-pages/docs/react/hooks-overview.mdx b/apps/docs/markdown-pages/docs/react/hooks-overview.mdx
index 55c7626ee..62d078e60 100644
--- a/apps/docs/markdown-pages/docs/react/hooks-overview.mdx
+++ b/apps/docs/markdown-pages/docs/react/hooks-overview.mdx
@@ -38,7 +38,7 @@ let make = () => {
setCount(prev => prev + 1)
}
- let msg = "You clicked" ++ Belt.Int.toString(count) ++ "times"
+ let msg = "You clicked" ++ Int.toString(count) ++ "times"
{React.string(msg)}
@@ -55,7 +55,7 @@ function Example(props) {
let match = React.useState(() => 0);
let setCount = match[1];
let onClick = (_evt) => setCount((prev) => (prev + 1) | 0);
- let msg = "You clicked" + String(match[0]) + "times";
+ let msg = "You clicked" + match[0].toString() + "times";
return JsxRuntime.jsxs("div", {
children: [
JsxRuntime.jsx("p", { children: msg }),
@@ -77,7 +77,7 @@ function Example(props) {
let match = React.useState(() => 0);
let setCount = match[1];
let onClick = (_evt) => setCount((prev) => (prev + 1) | 0);
- let msg = "You clicked" + String(match[0]) + "times";
+ let msg = "You clicked" + match[0].toString() + "times";
return (
{msg}
diff --git a/apps/docs/markdown-pages/docs/react/hooks-reducer.mdx b/apps/docs/markdown-pages/docs/react/hooks-reducer.mdx
index 4a39ddf79..e232ed274 100644
--- a/apps/docs/markdown-pages/docs/react/hooks-reducer.mdx
+++ b/apps/docs/markdown-pages/docs/react/hooks-reducer.mdx
@@ -64,7 +64,7 @@ let make = () => {
let (state, dispatch) = React.useReducer(reducer, {count: 0})
<>
- {React.string("Count:" ++ Belt.Int.toString(state.count))}
+ {React.string("Count:" ++ Int.toString(state.count))}
>
@@ -88,7 +88,7 @@ function Example(props) {
let dispatch = match[1];
return JsxRuntime.jsxs(JsxRuntime.Fragment, {
children: [
- "Count:" + String(match[0].count),
+ "Count:" + match[0].count.toString(),
JsxRuntime.jsx("button", {
children: "-",
onClick: (param) => dispatch("Dec"),
@@ -123,7 +123,7 @@ function Example(props) {
let dispatch = match[1];
return (
<>
- {"Count:" + String(match[0].count)}
+ {"Count:" + match[0].count.toString()}
>
@@ -176,7 +176,7 @@ let reducer = (state, action) =>
let todos = Array.filter(state.todos, todo => todo.id !== id)
{...state, todos: todos}
| ToggleTodo(id) =>
- let todos = Belt.Array.map(state.todos, todo =>
+ let todos = Array.map(state.todos, todo =>
if todo.id === id {
{
...todo,
@@ -198,7 +198,7 @@ let make = () => {
{todos: initialTodos, nextId: 2},
)
- let todos = Belt.Array.map(state.todos, todo =>
+ let todos = Array.map(state.todos, todo =>