
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeBased on the documentation, the most common reason PatchEvent.from(set(value)) appears to do nothing is that you're not actually calling the onChange callback with the PatchEvent.
PatchEvent.from() is just an action creator - it creates the patch event but doesn't trigger any updates by itself. You need to pass it to the onChange prop that Sanity provides to your custom component:
// ❌ This won't work - just creates the event but doesn't dispatch it
PatchEvent.from(set(value));
// ✅ This will work - passes the event to onChange
onChange(PatchEvent.from(set(value)));Here's a complete example of a working custom input component:
import { set, unset } from 'sanity'
export function MyCustomInput(props) {
const { onChange, value } = props
const handleChange = (event) => {
const inputValue = event.target.value
// Create and dispatch the patch event
onChange(
inputValue
? PatchEvent.from(set(inputValue))
: PatchEvent.from(unset())
)
}
return (
<input
type="text"
value={value || ''}
onChange={handleChange}
/>
)
}Key points:
onChange prop is passed to your component by Sanity's form systemonChange() with your PatchEvent to actually trigger the update'sanity' directly: import { set, unset, setIfMissing } from 'sanity'If you're still not seeing updates after calling onChange, double-check:
onChange prop correctlyYou can find more details in the PatchEvent documentation and this community answer about the same issue.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store