You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added support for React 18 by having the consumer own the versions of `react` and `react-reconciler`. If you are currently using React 17 only, and are rendering in the “remote” context, you will need to add a dependency on `react-reconciler^0.27.0`. If you are using React 18, you will need to manually install the version of `react-reconciler` that matches up to that version (currently, `^0.29.0`).
Copy file name to clipboardExpand all lines: packages/react/README.md
+40-11
Original file line number
Diff line number
Diff line change
@@ -16,17 +16,45 @@ or, using `npm`:
16
16
npm install @remote-ui/react --save
17
17
```
18
18
19
+
### React peer dependencies
20
+
21
+
This package also has peer dependencies on a few React-related packages, but the versions you need depend on the version of React you are using:
22
+
23
+
**React 17.x.x**: you will need to have React installed. Additionally, if you are in the “remote” environment, you will need a dependency on `react-reconciler` between greater than or equal to `0.26.0`, and less than `0.28.0`:
**React 17.0.0 and later**: you will need to have React installed. Additionally, if you are in the “remote” environment, you will need a dependency on `react-reconciler` between greater than or equal to `0.28.0`:
34
+
35
+
```
36
+
yarn add react react-reconciler
37
+
38
+
# or, with `npm`:
39
+
40
+
npm install react react-reconciler --save
41
+
```
42
+
43
+
If you are only using the utilities for [React host applications](#host-environment), you do not need to declare a dependency on `react-reconciler`.
44
+
19
45
## Usage
20
46
21
47
### Remote environment
22
48
23
-
#### `render()`
49
+
#### `createRoot()`
24
50
25
-
The main entrypoint for this package, `@remote-ui/react`, provides the custom React renderer that outputs instructions to a [`@remote-ui/core``RemoteRoot`](../core#remoteroot) object. This lets you use the remote-ui system for communicating patch updates to host components over a bridge, but have React help manage your stateful application logic. To run a React app against a `RemoteRoot`, use the `render` function exported by this library, passing in the remote root and your root React component:
51
+
The main entrypoint for this package, `@remote-ui/react`, provides the custom React renderer that outputs instructions to a [`@remote-ui/core``RemoteRoot`](../core#remoteroot) object. This lets you use the remote-ui system for communicating patch updates to host components over a bridge, but have React help manage your stateful application logic.
52
+
53
+
To run a React app against a `RemoteRoot`, use the `createRoot` function exported by this library. This API has a similar signature to [the equivalent `react-dom` API](https://reactjs.org/docs/react-dom-client.html#createroot), where you first pass the the remote root you are targeting, and then render your React component into it:
26
54
27
55
```tsx
28
56
// For convenience, this library re-exports several values from @remote-ui/core, like createRemoteRoot
As you add, remove, and update host components in your React tree, this renderer will output those operations to the `RemoteRoot`. Since remote components are just a combination of a name and allowed properties, they map exactly to React components, which behave the same way.
50
78
51
-
Updating the the root React element for a given remote root can be done by calling the `render()`function again. For example, the root React element can be updated in an effect to receive updated props when they change:
79
+
Updating the the root React element for a given remote root can be done by calling the `render()`method again. For example, the root React element can be updated in an effect to receive updated props when they change:
0 commit comments