Skip to content

Latest commit

 

History

History
61 lines (52 loc) · 1.3 KB

File metadata and controls

61 lines (52 loc) · 1.3 KB

Component prop onChange

Prop onChange mapping lvgl object event LV_EVENT_VALUE_CHANGED

interface PARAM_TYPE {
    target: componentInstance; // original target
    currentTarget: componentInstance; // current target object, not the original object
    stopPropagation: () => {}; // stop event bubble
    value: string;
}

interface CALLBACK_TYPE {
    (e: PARAM_TYPE): void;
}

Value

onClick callback with the following type

  • CALLBACK_TYPE[]
  • CALLBACK_TYPE
  • null

Usage

import { Input } from 'lvlgjs-ui'
import { useState } from 'react'

function Component () {
    const [value, setValue] = useState()
    return (
        <React.Fragment>
            {/* controlled */}
            <Input
              style={style.input}
              onFocus={() => console.log('focus')}
              onFocusStyle={style.onFocusStyle}
              onChange={(e) => setValue(e.value)}
              mode="password"
              value={value}
            />
            {/* not controlled */}
            <Input
              style={style.input}
              onFocus={() => console.log('focus')}
              onFocusStyle={style.onFocusStyle}
              mode="password"
            />
        </React.Fragment>
    )
}

const style = {
    input: {},
    onFocusStyle: {}
}

Demo

test/textarea/1