Error when editing field in local studio, resolved by starting over.
9 replies
Last updated: Mar 23, 2022
J
hello, i’m trying to follow this tutorial on Creating a custom input component. I make it to this point (https://youtu.be/Sg-H5CKc6Dk?t=686 ) — but whenever I edit the field in my local studio, i get an error I can’t figure out:
the error goes back to line 22:
not sure what i’m doing wrong here i think i’ve copied the example exactly
Uncaught TypeError: _formBuilder.default is undefined
the error goes back to line 22:
onChange(PatchEvent.from(inputValue ? … )
not sure what i’m doing wrong here i think i’ve copied the example exactly
Mar 17, 2022, 4:29 AM
V
Jimmy, can you please paste your component's code somewhere and send it here?
Mar 17, 2022, 4:56 AM
J
https://gist.github.com/jmcbroom/9d165e122ad70b5a70b37e0171534ff7 thanks for taking a look!
Mar 17, 2022, 11:46 AM
J
& in my `schema.js`:
{ title: 'Shape', name: 'shape', type: 'url', inputComponent: ShapeInput }
Mar 17, 2022, 11:46 AM
B
Hey Jimmy, thanks for your question. Out of curiosity maybe try rebuilding the studio after these changes are made and refreshing it in the browser. Also if possible can you re-post your
gistit seems to be out of date or not working when attempting to visit it to look over your code
Mar 17, 2022, 3:23 PM
J
import React, { useEffect, useState } from "react"; import PatchEvent, { set, unset } from "@sanity/form-builder"; import { FormField } from "@sanity/base/components"; import { TextInput } from '@sanity/ui'; const ShapeInput = React.forwardRef((props, ref) => { const { type, value, readOnly, placeholder, markers, presence, compareValue, onFocus, onBlur, onChange } = props; const handleChange = React.useCallback((event) => { const inputValue = event.currentTarget.value onChange(PatchEvent.from(inputValue ? set(inputValue) : unset())) }, [onChange]); return ( <FormField description={type.description} // Creates description from schema title={type.title} // Creates label from schema title __unstable_markers={markers} // Handles all markers including validation __unstable_presence={presence} // Handles presence avatars compareValue={compareValue} > <TextInput value={value} readOnly={readOnly} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onChange={handleChange} /> </FormField> ); }); export default ShapeInput;
Mar 17, 2022, 3:26 PM
J
rebuilt the studio (i.e. ran
sanity startagain); refreshed; still getting the same error
Mar 17, 2022, 3:27 PM
J
i figured this out! I don’t really know how 🙃 I just started over and it seemed to work
Mar 19, 2022, 3:10 AM
J
i figured this out! I don’t really know how 🙃 I just started over and it seemed to work
Mar 19, 2022, 3:10 AM
B
Glad to hear it!
Mar 23, 2022, 9:45 PM
Sanity– build remarkable experiences at scale
The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.