I am working on a custom extension with Js/React.
I would like to update the field of a specific record when someone clicks a button.
function updateField() {
let table = base.getTableByNameIfExists("Dart Applicant Tracker");
let record = useRecordById(table, "rec8XV8zW0GuGPBDX");
table.updateRecordAsync(record, {
"Scheduled Staff":
base._baseData["collaboratorsById"][base._baseData["currentUserId"]][
"email"
],
});
}
However, when I call my function I get the following error:
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the same app
It seems like I can't use these methods in a function. What is a workaround?