1.0.3 • Published 5 years ago

react-gforms v1.0.3

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

react-gforms

GForms for react

NPM JavaScript Style Guide

Install

npm install --save react-gforms

Usage

import * as React from "react";
import useGForms, {GFormField} from 'react-gforms';

const gformActionUrl: string =
  "https://docs.google.com/forms/d/e/ab123456-ojfiMZaDVu4U1lo6T7b7XrkzIE0V4mPQfllabcdefg/formResponse";

const ExampleForm: React.FC = () => {
  const gforms = useGForms(gformActionUrl, () => console.log("Sent!"));

  return (
    <div>
      <p>My form!</p>
      <GFormField
        gforms={gforms}
        nameAttribute="emailAddress"
        render={(value: any, setValue: (val: any) => void) => {
          return (
            <input
              type="text"
              value={value}
              onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
                setValue(e.target.value);
              }}
            />
          );
        }}
      />{" "}
      <GFormField
        gforms={gforms}
        nameAttribute="entry.1234567890"
        render={(value: any, setValue: (val: any) => void) => {
          return (
            <input
              type="text"
              value={value}
              onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
                setValue(e.target.value);
              }}
            />
          );
        }}
      />
      <div>
        <button onClick={gforms.submit}>Send</button>
      </div>
    </div>
  );
};

export default ExampleForm;

License

ISC © justinmahar