Skip to content

eslintinit/use-airtable

Repository files navigation

use-airtable

Airtable CRUD to be used in react components

NPM JavaScript Style Guide

Demo

Install

npm install --save airtable use-airtable

Usage

import { useAirtable } from 'use-airtable'

const TodoList = () => {
  const [records, createRecord, updateRecord, deleteRecord] = useAirtable(
    TABLE_NAME,
    AIRTABLE_API_KEY,
    TABLE_BASE_ID
  )

  return (
    <div>
      {records.map((record) => (
        <span>{record.fields.Name}</span>
      ))}
      <button onClick={() => createRecord({ Name: 'New record' })}>
        Add record
      </button>
    </div>
  )
}

Update

<button onClick={() => updateRecord(record.id, { Status: 'In progress' })}>
  Update
</button>

Delete

<button onClick={() => deleteRecord(record.id)}>Delete</button>

License

MIT © ignatif


This hook is created using create-react-hook.

About

Airtable CRUD hooks for React

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published