update
parent
f1698b4cb2
commit
6b63b9f8c6
|
@ -9,11 +9,11 @@
|
|||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<title>React App</title>
|
||||
<link rel="stylesheet" href="dist/index.css">
|
||||
<link rel="stylesheet" href="index.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<wc-test id='test' name='Evan'></wc-test>
|
||||
</body>
|
||||
<script src="dist/index.js"></script>
|
||||
<script src="index.js" type="module"></script>
|
||||
</html>
|
||||
|
|
19
index.js
19
index.js
|
@ -26,12 +26,8 @@ WcTestApp.defaultProps = {
|
|||
class WcTest extends HTMLElement {
|
||||
root;
|
||||
|
||||
// declare attributes we want to keep track of
|
||||
static get observedAttributes() {
|
||||
return ['name', 'onclick'];
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
constructor(){
|
||||
super()
|
||||
let mountPoint = this;
|
||||
|
||||
// ShadowRoot (global styles will not apply, but safer with a complete isolation layer)
|
||||
|
@ -41,14 +37,19 @@ class WcTest extends HTMLElement {
|
|||
this.render()
|
||||
}
|
||||
|
||||
render(){
|
||||
// declare attributes we want to keep track of
|
||||
static get observedAttributes() {
|
||||
return ['name', 'onclick'];
|
||||
}
|
||||
|
||||
// connectedCallback() {
|
||||
// }
|
||||
|
||||
render(){
|
||||
const name = this.hasAttribute('name')
|
||||
? this.getAttribute('name')
|
||||
: undefined;
|
||||
|
||||
console.log(this.root)
|
||||
|
||||
this.root.render(<WcTestApp name={name} />);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
"react-dom": "^18.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "yarn parcel index.js index.css",
|
||||
"build": "yarn parcel build index.js index.css"
|
||||
"start": "yarn parcel index.html",
|
||||
"build": "(rm -rf dist||true) && yarn parcel build index.html"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
|
|
Loading…
Reference in New Issue