Help

Welcome to the Airtable Community! If you're new here, check out our Getting Started area to get the most out of your community experience.

useRecordActionData and record.getCellValueAsString

130 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Zehava_Rubin
4 - Data Explorer
4 - Data Explorer

Hi, I created a custom extension and a button to call this extension from a specific record. 

I would like to use a field from that record in my code, but I keep on getting React errors because of the order in which it is loading.

I can't use record.getCellValueAsString within a useEffect hook to capture when useRecordActionData  is loaded as it is considered using a hook within a hook.

My end goal is to set number to the value in the Phone field of the selected record

TypeError: Cannot read properties of null (reading 'getCellValueAsString')

Any ideas would be helpful.

 

  const [number, setNumber] = useState("");
  let recordActionData = useRecordActionData();
  let base = useBase();
  let tableId = recordActionData == null ? "null" : recordActionData["tableId"];
  let recordId =
    recordActionData == null ? "null" : recordActionData["recordId"];
  let table = base.getTableByIdIfExists(tableId);
  let record = useRecordById(table, recordId);

  setNumber(record.getCellValueAsString("Phone #"));

 

 

0 Replies 0