Skip to content

Commit 13e33c8

Browse files
authored
Merge pull request #214 from reason-association/switch-to-rescript-react
Switch to rescript react
2 parents 8dddbb2 + d4646cd commit 13e33c8

16 files changed

+51
-50
lines changed

bsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"refmt": 3,
99
"bs-dependencies": [
10-
"reason-react",
10+
"@rescript/react",
1111
"bs-fetch",
1212
"@glennsl/bs-json",
1313
"@ryyppy/rescript-promise"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"prettier": "^1.18.2",
3030
"react": "^16.12.0",
3131
"react-dom": "^16.12.0",
32-
"reason-react": "^0.9.1",
32+
"@rescript/react": "^0.10.1",
3333
"remark-parse": "^7.0.1",
3434
"remark-slug": "^5.1.2",
3535
"remark-stringify": "^7.0.3",

pages/docs/gentype/latest/introduction.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ canonical: "/docs/gentype/latest/introduction"
99
`genType` is a code generation tool that lets you export ReScript values and types to use in JavaScript, and import JavaScript values and types into ReScript.
1010

1111
Converter functions between the two representations are generated based on the type of the value. The converters can be generated in vanilla JavaScript, or in [TypeScript](https://www.typescriptlang.org/) / [Flow](https://flow.org/en/) for a type-safe idiomatic interface.
12-
In particular, conversion of [ReasonReact](https://reasonml.github.io/reason-react/) components both ways is supported, with automatic generation of the wrappers.
12+
In particular, conversion of [rescript-react](/docs/react/latest/introduction) components both ways is supported, with automatic generation of the wrappers.
1313

1414
Here's an article describing how to use `genType` as part of a migration strategy where a tree of components is gradually converted to ReScript bottom-up (old article containing Reason / BuckleScript): [Adopting Reason: strategies, dual sources of truth, and why genType is a big deal](https://medium.com/p/c514265b466d).
1515

@@ -22,13 +22,13 @@ The output of genType can be configured by using one of 3 back-ends: `untyped` t
2222

2323
## A Quick Example
2424

25-
Let's assume we are working on a TypeScript (TS) codebase and we want to integrate a single ReasonReact component.
25+
Let's assume we are working on a TypeScript (TS) codebase and we want to integrate a single rescript-react component.
2626

27-
We want to be able to import the ReasonReact component like any other React component in our existing TS code, but we also want to preserve all the ReScript types in the TS type system (and convert incompatible values if necessary).
27+
We want to be able to import the rescript-react component like any other React component in our existing TS code, but we also want to preserve all the ReScript types in the TS type system (and convert incompatible values if necessary).
2828

2929
**That's exactly what genType was made for!**
3030

31-
First we'll set up a ReasonReact component:
31+
First we'll set up a rescript-react component:
3232

3333
```res
3434
/* src/MyComp.res */

pages/docs/gentype/latest/supported-types.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ In case of mixed named and unnamed arguments, consecutive named arguments form s
117117

118118
Function components are exported and imported exactly like normal functions. For example:
119119

120-
```reaspn
120+
```reason
121121
[@genType]
122122
[@react.component]
123123
let make = (~name) => React.string(name);

pages/docs/gentype/latest/usage.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ To import nested values, e.g. `Some.Nested.value`, use e.g. `@genType.import((".
7373

7474
## Export and Import React Components Using Deprecated Record API
7575

76+
**Important:** This section is only relevant for legacy [reason-react](https://github.com/reasonml/reason-react) codebases.
77+
7678
To export a ReasonReact component to JS, and automatically generate a wrapper for it, simply annotate the `make` function:
7779

7880
```res

pages/docs/manual/latest/installation.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ That compiles your ReScript into JavaScript, then uses NodeJS to run said JavaSc
3030

3131
During development, instead of running `npm run build` each time to compile, use `npm run start` to start a watcher that recompiles automatically after file changes.
3232

33-
Alternatively, **to start a [ReasonReact](https://reasonml.github.io/reason-react/en/) app**, follow the instructions [here](https://reasonml.github.io/reason-react/docs/en/installation).
33+
Alternatively, **to start a [rescript-react](/docs/react/latest/introduction) app**, follow the instructions [here](/docs/react/latest/installation).
3434

3535
## Integrate Into Existing JS Project
3636

@@ -89,20 +89,20 @@ You may also like to add two scripts to your `package.json` to help with compili
8989

9090
If you would like to enable React in your ReScript code, use the following additional steps:
9191

92-
Install [Reason React](https://reasonml.github.io/reason-react/en/).
92+
Install [rescript-react](/docs/react/latest/introduction). Here's the quick version:
9393

9494
```sh
95-
npm install reason-react
95+
npm install @rescript/react --save
9696
```
9797

9898
Make the following changes to your `bsconfig.json` file:
9999

100100
```json
101101
"reason": { "react-jsx": 3 },
102-
"bs-dependencies": ["reason-react"],
102+
"bs-dependencies": ["@rescript/react"],
103103
```
104104

105-
### Using the compiled code
105+
### Integration with the Existing Code
106106

107107
Since ReScript compiles to clean readable JS files the rest of your existing toolchain (e.g. Babel and Webpack) should just work.
108108

pages/docs/manual/latest/jsx.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "JSX"
3-
description: "JSX syntax in ReScript and ReasonReact"
3+
description: "JSX syntax in ReScript and React"
44
canonical: "/docs/manual/latest/jsx"
55
---
66

pages/docs/manual/v8.0.0/jsx.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "JSX"
3-
description: "JSX syntax in ReScript and ReasonReact"
3+
description: "JSX syntax in ReScript and React"
44
canonical: "/docs/manual/latest/jsx"
55
---
66

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module Friend = {
5656
```
5757
```res
5858
module Friend = {
59-
[@bs.obj]
59+
@obj
6060
external makeProps: (
6161
~name: string,
6262
~children: 'children,
@@ -99,7 +99,7 @@ module FancyInput = {
9999
```res
100100
// Simplified Output
101101
module FancyInput = {
102-
@bs.obj
102+
@obj
103103
external makeProps: (
104104
~className: 'className=?,
105105
~children: 'children,

pages/docs/react/latest/components-and-props.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,14 @@ var make = App;
330330

331331
You don't need to use the `@react.component` decorator to write components that can be used in JSX. Instead you can write a pair of `make` and `makeProps` functions such that type `makeProps: 'a => props` and `make: props => React.element` and these will always work as React components.
332332

333-
This works with your own version of `[@bs.obj]`, or any other function that takes named args and returns a single props structure. For example:
333+
This works with your own version of `@obj`, or any other function that takes named args and returns a single props structure. For example:
334334

335335
<CodeTab labels={["ReScript", "JS Output"]}>
336336

337337
```res
338338
module Link = {
339339
type props = {"href": string, "children": React.element};
340-
@bs.obj external makeProps:(
340+
@obj external makeProps:(
341341
~href: string,
342342
~children: React.element,
343343
unit) => props = ""
@@ -406,19 +406,19 @@ Because components are actually a pair of functions, they have to belong to a mo
406406

407407

408408
```res
409-
// File.re
409+
// File.res
410410
411411
// will be named `File` in dev tools
412-
[@react.component]
412+
@react.component
413413
let make = ...
414414
415415
// will be named `File$component` in dev tools
416-
[@react.component]
416+
@react.component
417417
let component = ...
418418
419419
module Nested = {
420420
// will be named `File$Nested` in dev tools
421-
[@react.component]
421+
@react.component
422422
let make = ...
423423
};
424424
```

0 commit comments

Comments
 (0)