Simple form management
TextInput
import React, { useCallback } from "react";
import TextField from "@material-ui/core/TextField";
import { useEventrixState } from "eventrix";
const TextInput = ({ onChange, value = "", type, label, name }) => {
const [inputValue = value, setInputValue] = useEventrixState(`form.${name}`);
const onInputChange = useCallback(
(e) => {
const newValue = e.target.value;
onChange(newValue);
setInputValue(newValue);
},
[setInputValue, onChange]
);
return (
<TextField
margin="dense"
id={name}
label={label}
type={type}
fullWidth
variant="outlined"
onChange={onInputChange}
value={inputValue}
/>
);
};
export default TextInput;Submit and clear form receivers
Form
Last updated
Was this helpful?