Simple form management

You can manage your form with eventrix using hooks. Full example you can find here

TextInput

TextInput use useEventrixState hook to update form state in eventrix.

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

Handle events of submit and clear form using EventsReceiver.

Form

Emit events about submit and clear form using useEmit hook.

Last updated

Was this helpful?