Error with code example in tutorial

Using this tutorial there is a small error that we got stuck on in part 4.

We ended up editing it this way I am sure something more elegant is what you guys had in mind. This is just an example.

function TodoBlock() {
    // YOUR CODE GOES HERE
    const base = useBase();
    const globalConfig = useGlobalConfig();
    const tableId = globalConfig.get('selectedTableId');
    const completedFieldId = globalConfig.get('completedFieldId');
    const table = base.getTableByIdIfExists(tableId);
    const completedField = table ? table.getFieldByIdIfExists(completedFieldId) : null;
    const toggle = (record) => {
        table.updateRecordAsync(
            record, {[completedFieldId]: !record.getCellValue(completedField)}
        );
    };    
    const records = useRecords(table);
    const tasks = records && completedField ? records.map(record => (
        <Task key={record.id} record={record} onToggle={toggle} completedFieldId={completedField} />
   )) : null;
    return (
        <div>
            <TablePickerSynced globalConfigKey="selectedTableId" />
            <FieldPickerSynced table={table} globalConfigKey="completedFieldId" />
            {tasks}
        </div>
    )
}

Hi @Holly_Gronau,

Thanks for writing in! Looking now, I see that there is a duplicate <TablePicker> in the sample code listed in the guide at this section. Is this the error you’re describing, or was it something else?

I’ll get a patch up for the duplicate <TablePicker> in any case, thanks for flagging!

Yes, thanks I am glad I posted this the community here seems very nice and super helpful. I have only been working on the custom block beta code since monday and so far it’s been really great so I just wanted to pass this along so no one else get’s stuck.

We are creating a custom block for sending data from airtable to Sanity.io similar to some of the custom wordpress blocks people have already created. If you know of anyone where who has attempted this with Sanity.io and posted please let me know if not if you are interested in our progress on this I am happy to post how it is going too.

This topic was solved and automatically closed 15 days after the last reply. New replies are no longer allowed.