Skip to content

Update React page #593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Nov 25, 2022
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a8ed657
add React v0.10.0 page
mununki Nov 5, 2022
cb98199
remove migration from react latest and
mununki Nov 5, 2022
3230a82
update introduction
mununki Nov 6, 2022
7baa1f4
update installation
mununki Nov 6, 2022
6ee8212
rename to migrate-from-v3
mununki Nov 6, 2022
9032111
add migrate from v3 page
mununki Nov 6, 2022
7298e51
add toc for extensions of props page
mununki Nov 6, 2022
e3a3416
update element and jsx page
mununki Nov 7, 2022
bb26f7a
update rendering-elements page
mununki Nov 7, 2022
e879b67
update components and props page
mununki Nov 10, 2022
be5a84f
update context page
mununki Nov 10, 2022
0ad6b84
update hooks-context page
mununki Nov 10, 2022
eab6d5b
update beyond jsx page
mununki Nov 10, 2022
2f53019
update forwarding-refs page
mununki Nov 10, 2022
ac95e33
update extensions of props page
mununki Nov 10, 2022
8cac94b
fix beyond jsx page
mununki Nov 10, 2022
0c07c9e
remove react.component from expanded
mununki Nov 11, 2022
9edae92
remove react.component
mununki Nov 11, 2022
9e334f1
add extensions of props page
mununki Nov 11, 2022
4d04878
Update pages/docs/react/latest/installation.mdx
mununki Nov 11, 2022
71e2dcd
remove the flow support of gentype
mununki Nov 11, 2022
ad5cde1
Update pages/docs/react/latest/beyond-jsx.mdx
mununki Nov 11, 2022
a9b7804
Update pages/docs/react/latest/beyond-jsx.mdx
mununki Nov 11, 2022
dfc240f
Update pages/docs/react/latest/migrate-from-v3.mdx
mununki Nov 11, 2022
d7107b4
Update pages/docs/react/latest/migrate-from-v3.mdx
mununki Nov 11, 2022
5e43270
add make function name comment
mununki Nov 11, 2022
3671316
Update pages/docs/react/latest/migrate-from-v3.mdx
mununki Nov 11, 2022
d082ac4
add automatic codes
mununki Nov 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update rendering-elements page
  • Loading branch information
mununki committed Nov 16, 2022
commit bb26f7ae8f43ebab23f71df31ab1d6b8fe7cab4e
11 changes: 7 additions & 4 deletions pages/docs/react/latest/rendering-elements.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ Here is a full example rendering our application in our `root` div:
```res
// Dom access can actually fail. ReScript
// is really explicit about handling edge cases!
switch(ReactDOM.querySelector("#root")){
| Some(root) => ReactDOM.render(<div> {React.string("Hello Andrea")} </div>, root)
| None => () // do nothing
switch ReactDOM.querySelector("#root") {
| Some(rootElement) => {
let root = ReactDOM.Client.createRoot(rootElement)
ReactDOM.Client.Root.render(root, <div />)
}
| None => ()
}
```
```js
Expand All @@ -60,6 +63,6 @@ if (!(root == null)) {

React elements are immutable. Once you create an element, you can’t change its children or attributes. An element is like a single frame in a movie: it represents the UI at a certain point in time.

At this point we would need to understand a few more concepts, such as React components and state management to be able to update the rendered elements after the initial `ReactDOM.render`. For now, just imagine your React application as a tree of elements, whereby some elements may get replaced during the lifetime of your application.
At this point we would need to understand a few more concepts, such as React components and state management to be able to update the rendered elements after the initial `ReactDOM.Client.Root.render`. For now, just imagine your React application as a tree of elements, whereby some elements may get replaced during the lifetime of your application.

React will automatically recognize any element changes and will only apply the DOM updates necessary to bring the DOM to the desired state.