Airtable CRUD to be used in react components
npm install --save airtable use-airtable
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>
)
}
<button onClick={() => updateRecord(record.id, { Status: 'In progress' })}>
Update
</button>
<button onClick={() => deleteRecord(record.id)}>Delete</button>
MIT © ignatif
This hook is created using create-react-hook.