I have a react component
import React from 'react';
import classes from './Input.module.css';
import PlayCircleFilledWhiteIcon from '@material-ui/icons/PlayCircleFilledWhite';
export const Input = ({ trackHandler }) => {
const handleTrack = (e) => {
if(e.key === 'Enter') {
trackHandler(e.target.value);
e.target.value = '';
}
}
return (
<>
<div className = {classes.forma}>
<input
type="text"
maxLength = '30'
placeholder = 'Enter tracker name'
onKeyPress = {e => handleTrack(e)}
className = {classes.inputText}
/>
<PlayCircleFilledWhiteIcon className = {classes.btnSubmit}/>
</div>
</>
)
}
Function trackHandler pass the value from input to another component.
I need to pass this value in two ways: by press key 'Enter' on keyboard or click on button. I've realised first way but I need to create both of them.
Thanks in advance for helping.