mirror of
https://github.com/usatiuk/ustk-todolist.git
synced 2025-10-28 23:57:49 +01:00
git-subtree-dir: react git-subtree-mainline:53976e7b43git-subtree-split:e508ac031e
35 lines
565 B
JavaScript
35 lines
565 B
JavaScript
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
function Input(props) {
|
|
let input;
|
|
|
|
function submit() {
|
|
if (input.value.trim() !== '') {
|
|
props.onClick(input.value);
|
|
}
|
|
input.value = '';
|
|
}
|
|
|
|
return (
|
|
<div id="inputs">
|
|
<input
|
|
ref={node => {
|
|
input = node;
|
|
}}
|
|
id="input"
|
|
type="text"
|
|
/>
|
|
<button id="add" onClick={() => submit()}>
|
|
add
|
|
</button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
Input.propTypes = {
|
|
onClick: PropTypes.func.isRequired,
|
|
};
|
|
|
|
export default Input;
|