I’m working on a custom Airtable block application that pulls data from various tables and presents them in a cohesive manner, allowing for interactivity. I’m utilizing the useRecords hook to ensure any changes made by users are reflected live in the application. However, I’ve discovered that the application reloads multiple times, correlated with each useRecords invocation, leading to sluggish performance. How can I effectively manage this situation to maintain real-time data access without causing frequent application restarts?**
Here’s a snippet of my code:
import { initializeBlock, useBase, useRecords } from '@airtable/blocks/ui';
import React from 'react';
function CustomBlock() {
const base = useBase();
const dataTables = React.useMemo(() => {
return {
productData: base.getTableByNameIfExists(Constants.PRODUCTS_TABLE),
pricingData: base.getTableByNameIfExists(Constants.COSTS_TABLE),
clientData: base.getTableByNameIfExists(Constants.CONTACTS_TABLE),
conversionData: base.getTableByNameIfExists(Constants.CONVERSIONS_TABLE),
authorData: base.getTableByNameIfExists(Constants.CONTRIBUTORS_TABLE),
};
}, [base]);
const conversions = useRecords(dataTables.conversionData);
const authors = useRecords(dataTables.authorData);
const pricing = useRecords(dataTables.pricingData);
const products = useRecords(dataTables.productData);
const clients = useRecords(dataTables.clientData);
}