Skip to content

Commit 9859d87

Browse files
Merge pull request #7 from canjs/update-docs
Fixes/cleanups to build and docs
2 parents 834624c + 1f6b1a3 commit 9859d87

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class Greeting extends React.Component {
1919
}
2020
```
2121

22-
Call `reactToWebComponent` and [customElements.define](https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define) as follows:
22+
Call `reactToCanWebComponent` and [customElements.define](https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define) as follows:
2323

2424
```js
25-
import reactToWebComponent from "react-to-can-webcomponent";
25+
import reactToCanWebComponent from "react-to-can-webcomponent";
2626

27-
const WebGreeting = reactToWebComponent(Greeting, React, ReactDOM);
27+
const WebGreeting = reactToCanWebComponent(Greeting, React, ReactDOM);
2828

2929
customElements.define("web-greeting", WebGreeting);
3030
```
@@ -55,7 +55,7 @@ document.body.firstChild.innerHTML //-> "<h1>Hello, CoolBeans</h1>"
5555

5656
### Working with Attributes
5757

58-
By default, custom elements created by `reactToWebComponent` only
58+
By default, custom elements created by `reactToCanWebComponent` only
5959
pass properties to the underlying React component. To make attributes
6060
work, you must specify your component's properties with
6161
[PropTypes](https://reactjs.org/docs/typechecking-with-proptypes.html) as follows:
@@ -72,7 +72,7 @@ Greeting.propTypes = {
7272
};
7373
```
7474

75-
Now `reactToWebComponent` will know to look for `name` attributes
75+
Now `reactToCanWebComponent` will know to look for `name` attributes
7676
as follows:
7777

7878
```js
@@ -94,11 +94,11 @@ npm i react-to-can-webcomponent
9494

9595
#### CodePen
9696

97-
[Greeting example in a CodePen](https://codepen.io/justinbmeyer/pen/gOYrQax?editors=1010)
97+
[Greeting example in a CodePen](https://codepen.io/bmomberger-bitovi/pen/BaybzQX?editors=1010)
9898

9999
## API
100100

101-
`reactToWebComponent(ReactComponent, React, ReactDOM)` takes the following:
101+
`reactToCanWebComponent(ReactComponent, React, ReactDOM)` takes the following:
102102

103103
- `ReactComponent` - A react component that you want to
104104
convert to a Web Component.
@@ -111,13 +111,13 @@ returned. This class can be directly passed to `customElements.define` as follow
111111

112112
```js
113113
customElements.define("web-greeting",
114-
reactToWebComponent(Greeting, React, ReactDOM) );
114+
reactToCanWebComponent(Greeting, React, ReactDOM) );
115115
```
116116

117117
Or the class can be defined and used later:
118118

119119
```js
120-
const WebGreeting = reactToWebComponent(Greeting, React, ReactDOM);
120+
const WebGreeting = reactToCanWebComponent(Greeting, React, ReactDOM);
121121

122122
customElements.define("web-greeting", WebGreeting);
123123

@@ -128,7 +128,7 @@ document.body.appendChild(myGreeting);
128128
Or the class can be extended:
129129

130130
```js
131-
class WebGreeting extends reactToWebComponent(Greeting, React, ReactDOM)
131+
class WebGreeting extends reactToCanWebComponent(Greeting, React, ReactDOM)
132132
{
133133
disconnectedCallback(){
134134
super.disconnectedCallback();
@@ -140,14 +140,14 @@ customElements.define("web-greeting", WebGreeting);
140140

141141
### How it works
142142

143-
`reactToWebComponent` creates a constructor function whose prototype is a [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy). This acts as a trap for any property set on instances of the custom element. When a property is set, the proxy:
143+
`reactToCanWebComponent` creates a constructor function whose prototype is a [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy). This acts as a trap for any property set on instances of the custom element. When a property is set, the proxy:
144144

145145
- re-renders the React component inside the custom element.
146146
- creates an enumerable getter / setter on the instance
147147
to save the set value and avoid hitting the proxy in the future.
148148
- sets up an observer to listen for observable properties that are read by the component.
149-
(Note: this is the only difference between this library and
150-
[Bitovi's react-to-webcomponent library](https://github.com/bitovi/react-web-component) )
149+
(Note: this is the only difference between this library and
150+
[Bitovi's react-to-webcomponent library](https://github.com/bitovi/react-to-webcomponent) )
151151

152152
Also:
153153

build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ stealTools.export({
1717
removeDevelopmentCode: false,
1818
useNormalizedDependencies: true,
1919
exports: {
20-
"react-to-webcomponent": "reactToWebComponent"
20+
"react-to-can-webcomponent": "reactToCanWebComponent"
2121
},
2222
normalize: function(depName, depLoad, curName, curLoad, loader){
2323
return baseNormalize.call(this, depName, depLoad, curName, curLoad, loader, true);

0 commit comments

Comments
 (0)