7
7
700Hp2021-12-13 12:11:25
typescript
700Hp, 2021-12-13 12:11:25

How to define a value change function in an input managed bean?

Input Component:

import React from 'react'
import classes from "./AppInput.module.css"

interface Input {
  placeholder: string,
  type: string,
  value: string,
  // Тут, как я понял, нужно определить onChange,  но как это должно выглядить?
 // Аналогичный вопрос к определению keyDown
}

const AppInput: React.FC<Input> = ({placeholder, type, value, onChange}) => {

    return (
        <input className={classes.input}  placeholder={placeholder} type={type} value={value} onChange={onchange}/>
    )
}

export default AppInput


parent component
<AppInput type="text" placeholder="Какой-то текст." value={value} onChange={(e) => setValue(e.target.value)} onKeyDown={enterKey} />

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-12-13
@700Hp

onChange: (event: React.ChangeEvent<HTMLInputElement>) => void

onKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void

Search here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question