@@ -27,13 +27,13 @@ You have two choices for writing web components: **Class-based** or **function-b
27
27
28
28
::: code-group
29
29
30
- ``` js [Class Based]
30
+ ``` tsx [Class Based]
31
31
@Component ({ name: " app-element" , css: styles })
32
32
export class App extends JwcComponent {
33
- constructor () { super (); }
33
+ constructor () { super (); }
34
34
35
- @Prop ({ default: 0 , attr: " count" }) count = 0 ;
36
- public onClick = () => { this .count ++ ; }}
35
+ @Prop ({ default: 0 , attr: " count" }) count = 0 ;
36
+ public onClick = () => { this .count ++ }}
37
37
38
38
override render () {
39
39
return (
@@ -48,13 +48,28 @@ export class App extends JwcComponent {
48
48
49
49
```
50
50
51
- ``` js [Function Based <Badge text="Not yet implemented" type="danger"/>]
52
- // no yet implemented
51
+ ``` tsx [Function Based <Badge text="Not yet implemented" type="danger"/>]
52
+ // no yet implemented // [!code focus]
53
+
54
+ export function App() {
55
+ const [count, setCount] = useProp <number >(0 );
56
+ const onClick = () => {
57
+ setCount (count + 1 );
58
+ };
59
+
60
+ return (
61
+ <div class = { " card" } >
62
+ <button onClick = { onClick } >count is { String (count )} </button >
63
+ </div >
64
+ );
65
+ }
66
+
67
+ registerComponent (" app-element" , App , styles );
53
68
```
54
69
55
70
:::
56
71
57
- With the example code and css style, you can create your own web component, like this: * (If you can't see this component, refresh it and try again)*
72
+ With the example code and css style, you can create your own web component, like this: _ (If you can't see this component, refresh it and try again)_
58
73
59
74
<app-element count =" 2022 " ></app-element >
60
75
0 commit comments