mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fixes example in Web Components docs (#11039)
* fixes docs on webcomponent * Update web-components.md
This commit is contained in:
committed by
Dan Abramov
parent
1ba7dfcf04
commit
e0b802fc4e
@@ -41,8 +41,10 @@ function BrickFlipbox() {
|
||||
|
||||
## Using React in your Web Components
|
||||
|
||||
Similarly, you can call `ReactDOM.render()` from inside a web component:
|
||||
|
||||
```javascript
|
||||
class XSearch {
|
||||
class XSearch extends HTMLElement {
|
||||
connectedCallback() {
|
||||
const mountPoint = document.createElement('span');
|
||||
this.attachShadow({ mode: 'open' }).appendChild(mountPoint);
|
||||
@@ -54,3 +56,7 @@ class XSearch {
|
||||
}
|
||||
customElements.define('x-search', XSearch);
|
||||
```
|
||||
|
||||
>Note:
|
||||
>
|
||||
>This code will **not** work if compiled with Babel [due to an intentional limitation in the specification](https://github.com/w3c/webcomponents/issues/587). It will only work if you use the `class` syntax directly in the browser without compiling the code first.
|
||||
|
||||
Reference in New Issue
Block a user