/
githubmirror
/
preact
Обзор
Документация
Войти
/
githubmirror
/
preact
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
demo/key_bug.jsx
32 строки
571 B
Jiawen Geng
feat: migrate demo to vite
08 май 2023, 12:49
08 май 2023, 12:49
e4f3522
Код
Авторство
О чём код?
import { Component } from 'preact'; function Foo(props) { return <div>This is: {props.children}</div>; } export default class KeyBug extends Component { constructor() { super(); this.onClick = this.onClick.bind(this); this.state = { active: false }; } onClick() { this.setState(prev => ({ active: !prev.active })); } render() { return ( <div> {this.state.active && <Foo>foo</Foo>} <h1>Hello World</h1> <br /> <Foo> bar <Foo>bar</Foo> </Foo> <br /> <button onClick={this.onClick}>Toggle</button> </div> ); } }