Skip to content

Commit 1334d3d

Browse files
author
Christopher J Baker
committed
Merge remote-tracking branch 'origin/main' into experimental-children
2 parents 04cd729 + 5d1bc1f commit 1334d3d

File tree

9 files changed

+373
-477
lines changed

9 files changed

+373
-477
lines changed

README.md

+19-38
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@
22

33
`@r2wc/react-to-web-component` converts [React](https://reactjs.org/) components to [custom elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements)! It lets you share React components as native elements that **don't** require being mounted through React. The custom element acts as a wrapper for the underlying React component. Use these custom elements with any project that uses HTML even in any framework (vue, svelte, angular, ember, canjs) the same way you would use standard HTML elements.
44

5+
> Note: The latest version of this package only works with the React 18. If you are using React 16 or 17, please use version 1.
6+
57
`@r2wc/react-to-web-component`:
68

79
- Works in all modern browsers. (Edge needs a [customElements polyfill](https://github.com/webcomponents/polyfills/tree/master/packages/custom-elements)).
8-
- Is `1.11KB` minified and gzipped.
10+
- Is `1.26KB` minified and gzipped.
11+
12+
## Setup
13+
14+
To install from npm:
15+
16+
```
17+
npm install @r2wc/react-to-web-component
18+
```
919

1020
## Need help or have questions?
1121

@@ -46,8 +56,6 @@ Now we can use `<web-greeting>` like any other HTML element!
4656
</body>
4757
```
4858

49-
Note that by using React 18, `r2wc` will use the new root API. If your application needs the legacy API, please use React 17
50-
5159
In the above case, the web-greeting custom element is not making use of the `name` property from our `Greeting` component.
5260

5361
## Working with Attributes
@@ -81,25 +89,15 @@ For projects needing more advanced usage of the web components, see our [program
8189

8290
We also have a [complete example using a third party library](docs/complete-example.md).
8391

84-
## Setup
85-
86-
To install from npm:
92+
## Examples
8793

88-
```
89-
npm install @r2wc/react-to-web-component
90-
```
94+
* [Hello World](https://codesandbox.io/s/hello-world-md5oih) - The quintessential software demo!
95+
* [All the Props](https://codesandbox.io/s/all-the-props-n8z5hv) - A demo of all the prop transform types that R2WC supports.
96+
* [Header Example](https://codesandbox.io/s/example-header-blog-7k313l) - An example reusable Header component.
97+
* [MUI Button](https://codesandbox.io/s/example-mui-button-qwidh9) - An example application using an MUI button with theme customization.
98+
* [Checklist Demo](https://codesandbox.io/s/example-checklist-blog-y3nqwx) - An example Checklist application.
9199

92-
## External Examples
93-
94-
Greeting example in [CodeSandbox](https://codesandbox.io/s/sample-greeting-app-ts-qwidh9)
95-
96-
Hello, world example (React17) in [CodeSandbox](https://codesandbox.io/s/hello-world-react17-u4l3x1)
97-
98-
Example with all prop types in [CodeSandbox](https://codesandbox.io/p/sandbox/vite-example-with-numerous-types-gjf87o)
99-
100-
R2WC With Vite Header Example in [CodeSandbox](https://codesandbox.io/p/sandbox/r2wc-header-example-vqzfgo)
101-
102-
## External Blog Posts
100+
## Blog Posts
103101

104102
R2WC with Vite [View Post](https://www.bitovi.com/blog/react-everywhere-with-vite-and-react-to-webcomponent)
105103

@@ -112,30 +110,13 @@ Check out our [full API documentation](https://github.com/bitovi/react-to-web-co
112110
Under the hood, `r2wc` creates a `CustomElementConstructor` with custom getters/setters and life cycle methods that keep track of the props that you have defined. When a property is set, its custom setter:
113111

114112
- re-renders the React component inside the custom element.
115-
- creates an enumerable getter / setter on the instance
116-
to save the set value and avoid hitting the proxy in the future.
113+
- creates an enumerable getter / setter on the instance to save the set value and avoid hitting the proxy in the future.
117114

118115
Also:
119116

120117
- Enumerable properties and values on the custom element are used as the `props` passed to the React component.
121118
- The React component is not rendered until the custom element is inserted into the page.
122119

123-
# Tests
124-
125-
To run tests, first run:
126-
127-
```
128-
npm run buildtests
129-
```
130-
131-
This copies the root test file into each of the `/tests/react*` versioned folders, modifies the ReactDOM import for older versions, and installs the corresponding version of react in that directory.
132-
133-
Then run:
134-
135-
```
136-
npm run test
137-
```
138-
139120
# We want to hear from you.
140121

141122
Come chat with us about open source in our Bitovi community [Discord](https://discord.gg/J7ejFsZnJ4).

package-lock.json

+77-82
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)