Skip to content

Commit a13044c

Browse files
committed
Migrate to Core
1 parent 0035ddb commit a13044c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+896
-967
lines changed

misc_docs/syntax/decorator_module.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var root = Path.dirname("/User/github");
3636
<CodeTab labels={["ReScript", "JS Output (Module)"]}>
3737
```rescript
3838
@module({from: "./myJson.json", with: {type_: "json", \"some-exotic-identifier": "someValue"}})
39-
external myJson: Js.Json.t = "default"
39+
external myJson: JSON.t = "default"
4040
4141
Console.log(myJson)
4242
```

pages/docs/manual/latest/primitive-types.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ As `bigint` is a different data type than `int`, it's necessary to open the corr
180180
<CodeTab labels={["ReScript", "JS Output"]}>
181181

182182
```res example
183-
open! Js.BigInt
183+
open! BigInt
184184
185185
let a = 9007199254740991n + 9007199254740991n
186186
let b = 2n ** 2n
@@ -198,7 +198,7 @@ It also supports all the bitwise operations, except unsigned shift right (`>>>`)
198198
<CodeTab labels={["ReScript", "JS Output"]}>
199199

200200
```res example
201-
open! Js.BigInt
201+
open! BigInt
202202
203203
let a = land(1n, 1n)
204204
let b = lor(1n, 1n)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ type props<'className, 'children, 'ref> = {
9999
100100
let make = (
101101
{?className, children, _}: props<'className, 'children, ReactRef.currentDomRef>,
102-
ref: Js.Nullable.t<ReactRef.currentDomRef>,
102+
ref: Nullable.t<ReactRef.currentDomRef>,
103103
) =>
104104
make(~className, ~children, ~ref, ())
105105
```

pages/docs/react/latest/forwarding-refs.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ module FancyInput = {
5656
5757
@react.component
5858
let make = () => {
59-
let input = React.useRef(Js.Nullable.null)
59+
let input = React.useRef(Nullable.null)
6060
6161
let focusInput = () =>
6262
input.current
63-
->Js.Nullable.toOption
64-
->Belt.Option.forEach(input => input->focus)
63+
->Nullable.toOption
64+
->Option.forEach(input => input->focus)
6565
6666
let onClick = _ => focusInput()
6767
@@ -96,7 +96,7 @@ module FancyInput = {
9696
<input
9797
type_="text"
9898
?className
99-
ref=?{Js.Nullable.toOption(ref)->Belt.Option.map(ReactDOM.Ref.domRef)}
99+
ref=?{Nullable.toOption(ref)->Option.map(ReactDOM.Ref.domRef)}
100100
/>
101101
children
102102
</div>
@@ -107,10 +107,10 @@ module FancyInput = {
107107
108108
@react.component
109109
let make = () => {
110-
let input = React.useRef(Js.Nullable.null)
110+
let input = React.useRef(Nullable.null)
111111
112112
let focusInput = () =>
113-
input.current->Js.Nullable.toOption->Belt.Option.forEach(input => input->focus)
113+
input.current->Nullable.toOption->Option.forEach(input => input->focus)
114114
115115
let onClick = _ => focusInput()
116116

pages/docs/react/latest/hooks-reducer.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ type state = {
125125
let reducer = (state, action) =>
126126
switch action {
127127
| AddTodo(content) =>
128-
let todos = Js.Array2.concat(
128+
let todos = Array.concat(
129129
state.todos,
130130
[{id: state.nextId, content: content, completed: false}],
131131
)
132132
{todos: todos, nextId: state.nextId + 1}
133133
| RemoveTodo(id) =>
134-
let todos = Js.Array2.filter(state.todos, todo => todo.id !== id)
134+
let todos = Array.filter(state.todos, todo => todo.id !== id)
135135
{...state, todos: todos}
136136
| ToggleTodo(id) =>
137137
let todos = Belt.Array.map(state.todos, todo =>

pages/docs/react/latest/hooks-ref.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ More infos on direct DOM manipulation can be found in the [Refs and the DOM](./r
5656
5757
@react.component
5858
let make = () => {
59-
let inputEl = React.useRef(Js.Nullable.null)
59+
let inputEl = React.useRef(Nullable.null)
6060
6161
let onClick = _ => {
6262
inputEl.current
63-
->Js.Nullable.toOption
64-
->Belt.Option.forEach(input => input->focus)
63+
->Nullable.toOption
64+
->Option.forEach(input => input->focus)
6565
}
6666
6767
<>
@@ -104,15 +104,15 @@ Reusing the example from our [Refs and the DOM](./refs-and-the-dom#callback-refs
104104
105105
@react.component
106106
let make = () => {
107-
let textInput = React.useRef(Js.Nullable.null)
107+
let textInput = React.useRef(Nullable.null)
108108
let setTextInputRef = element => {
109109
textInput.current = element;
110110
}
111111
112112
let focusTextInput = _ => {
113113
textInput.current
114-
->Js.Nullable.toOption
115-
->Belt.Option.forEach(input => input->focus)
114+
->Nullable.toOption
115+
->Option.forEach(input => input->focus)
116116
}
117117
118118
<div>

pages/docs/react/latest/lazy-components.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ Now we can dynamically import the `<Title/>` component by passing the result of
3333
```rescript
3434
// SomeOtherFile.res
3535
module LazyTitle = {
36-
let make = React.lazy_(() => Js.import(Title.make))
36+
let make = React.lazy_(() => import(Title.make))
3737
}
3838
3939
let titleJsx = <LazyTitle text="Hello!" />
4040
```
4141

4242
That's all the code we need! The new `<LazyTitle />` component behaves exactly the same as the wrapped `<Title />` component, but will be lazy loaded via React's built-in lazy mechanism.
4343

44-
> You can read more about `Js.import` and dynamic import in ReScript in [this part of the documentation](/docs/manual/latest/import-from-export-to-js#dynamic-import).
44+
> You can read more about `import` and dynamic import in ReScript in [this part of the documentation](/docs/manual/latest/import-from-export-to-js#dynamic-import).

pages/docs/react/latest/migrate-react.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ module FancyInput = {
148148
<input
149149
type_="text"
150150
?className
151-
ref=?{ref_->Js.Nullable.toOption->Belt.Option.map(ReactDOM.Ref.domRef)}
151+
ref=?{ref_->Nullable.toOption->Option.map(ReactDOM.Ref.domRef)}
152152
/>
153153
children
154154
</div>
@@ -157,7 +157,7 @@ module FancyInput = {
157157
158158
@react.component
159159
let make = () => {
160-
let input = React.useRef(Js.Nullable.null)
160+
let input = React.useRef(Nullable.null)
161161
162162
<div>
163163
<FancyInput ref=input> // prop
@@ -181,7 +181,7 @@ module FancyInput = {
181181
<input
182182
type_="text"
183183
?className
184-
ref=?{ref->Js.Nullable.toOption->Belt.Option.map(ReactDOM.Ref.domRef)}
184+
ref=?{ref->Nullable.toOption->Option.map(ReactDOM.Ref.domRef)}
185185
/>
186186
children
187187
</div>
@@ -190,7 +190,7 @@ module FancyInput = {
190190
191191
@react.component
192192
let make = () => {
193-
let input = React.useRef(Js.Nullable.null)
193+
let input = React.useRef(Nullable.null)
194194
195195
<div>
196196
<FancyInput ref=input>

pages/docs/react/latest/refs-and-the-dom.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let value = myRef.current
6464
```
6565

6666
The value of the ref differs depending on the type of the node:
67-
- When the ref attribute is used on an HTML element, the ref passed via `ReactDOM.Ref.domRef` receives the underlying DOM element as its current property (type of `React.ref<Js.Nullable.t<Dom.element>>`)
67+
- When the ref attribute is used on an HTML element, the ref passed via `ReactDOM.Ref.domRef` receives the underlying DOM element as its current property (type of `React.ref<Nullable.t<Dom.element>>`)
6868
- In case of interop, when the ref attribute is used on a custom class component (based on JS classes), the ref object receives the mounted instance of the component as its current (not discussed in this document).
6969
- **You may not use the ref attribute on component functions** because they don’t have instances (we don't expose JS classes in ReScript).
7070

@@ -83,10 +83,10 @@ This code uses a `React.ref` to store a reference to an `input` DOM node to put
8383
8484
@react.component
8585
let make = () => {
86-
let textInput = React.useRef(Js.Nullable.null)
86+
let textInput = React.useRef(Nullable.null)
8787
8888
let focusInput = () =>
89-
switch textInput.current->Js.Nullable.toOption {
89+
switch textInput.current->Nullable.toOption {
9090
| Some(dom) => dom->focus
9191
| None => ()
9292
}
@@ -126,7 +126,7 @@ function CustomTextInput(Props) {
126126

127127
A few things happened here, so let's break them down:
128128

129-
- We initialize our `textInput` ref as a `Js.Nullable.null`
129+
- We initialize our `textInput` ref as a `Nullable.null`
130130
- We register our `textInput` ref in our `<input>` element with `ReactDOM.Ref.domRef(textInput)`
131131
- In our `focusInput` function, we need to first verify that our DOM element is set, and then use the `focus` binding to set the focus
132132

@@ -148,7 +148,7 @@ module MyComp = {
148148
149149
@react.component
150150
let make = () => {
151-
let textInput = React.useRef(Js.Nullable.null)
151+
let textInput = React.useRef(Nullable.null)
152152
153153
// This will **not** work
154154
<MyComp ref={ReactDOM.Ref.domRef(textInput)} />
@@ -193,15 +193,15 @@ The example below implements a common pattern: using the ref callback to store a
193193
194194
@react.component
195195
let make = () => {
196-
let textInput = React.useRef(Js.Nullable.null)
196+
let textInput = React.useRef(Nullable.null)
197197
let setTextInputRef = element => {
198198
textInput.current = element;
199199
}
200200
201201
let focusTextInput = _ => {
202202
textInput.current
203-
->Js.Nullable.toOption
204-
->Belt.Option.forEach(input => input->focus)
203+
->Nullable.toOption
204+
->Option.forEach(input => input->focus)
205205
}
206206
207207
<div>
@@ -261,7 +261,7 @@ module CustomTextInput = {
261261
262262
@react.component
263263
let make = () => {
264-
let textInput = React.useRef(Js.Nullable.null)
264+
let textInput = React.useRef(Nullable.null)
265265
let setInputRef = element => { textInput.current = element}
266266
267267
<CustomTextInput setInputRef/>

0 commit comments

Comments
 (0)