0.3.0 • Published 5 days ago

@lcui/react v0.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 days ago

@lcui/react

(中文/English)

一个用于 LCUI 应用程序开发的 React 库,提供 TypeScript 类型声明、React 版预置组件,配合 @lcui/cli 使用。

安装

npm install -D @lcui/react

使用

import { useState, useRef, TextInput, Button } from '@lcui/react';
import styles from './app.module.css';

export default function App() {
  const inputRef = useRef();
  const [name, setName] = useState('World');

  return (
    <div className={styles.app}>
      Hello, {name}!
      <TextInput ref={inputRef} placeholder="Please input..." />
      <Button onClick={() => setName(inputRef.current.value)}>Change</Button>
    </div>
  );
}

LCUI 并不是浏览器引擎,像按钮、文本输入框等原生控件需要由特定的 LCUI 组件实现,因此,在 JSX 写法上会有如下差异:

  <div className={styles.app}>
    Hello, World!
-   <input placeholder="Please input..." />
+   <TextInput placeholder="Please input..." />
-   <button>Click here</button>
+   <Button>Click here</Button>
  <div>

许可

MIT

0.3.0

5 days ago

0.2.1

5 months ago

0.2.0

5 months ago

0.1.0

7 months ago