File tree Expand file tree Collapse file tree 2 files changed +21
-19
lines changed
packages/feedback-screenshot/src Expand file tree Collapse file tree 2 files changed +21
-19
lines changed Original file line number Diff line number Diff line change 1- import { Component , h } from 'preact' ;
1+ import { h , render } from 'preact' ;
2+ import { useState , useCallback } from 'preact/hooks' ;
3+ import type { VNode } from 'preact' ;
24
3- export class ScreenshotButton extends Component {
4- state = { clicked : false } ;
5- handleClick = ( ) => {
6- this . setState ( { clicked : ! this . state . clicked } ) ;
7- } ;
8- render ( ) {
9- return (
10- < label htmlFor = "screenshot" className = "form__label" >
11- < span className = "form__label__text" > Screenshot</ span >
12- < button class = "btn btn--default" type = "screenshot" onClick = { this . handleClick } >
13- { this . state . clicked ? 'Remove' : 'Add' }
14- </ button >
15- </ label >
16- ) ;
17- }
5+ export function ScreenshotButton ( ) : VNode {
6+ const [ clicked , setClicked ] = useState ( false ) ;
7+ const handleClick = useCallback ( ( ) => {
8+ setClicked ( prev => ! prev ) ;
9+ } , [ ] ) ;
10+
11+ return (
12+ < label htmlFor = "screenshot" className = "form__label" >
13+ < span className = "form__label__text" > Screenshot</ span >
14+ < button class = "btn btn--default" type = "screenshot" onClick = { handleClick } >
15+ { clicked ? 'Remove' : 'Add' }
16+ </ button >
17+ </ label >
18+ ) ;
1819}
Original file line number Diff line number Diff line change 1- import { h } from 'preact' ;
2- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
3- export function ScreenshotWidget ( ) {
1+ import { h , render } from 'preact' ;
2+ import type { VNode } from 'preact' ;
3+
4+ export function ScreenshotWidget ( ) : VNode {
45 return < div style = "height:100px; width: 100px; background:red;" /> ;
56}
You can’t perform that action at this time.
0 commit comments