Accessing parent schema values in custom input components changed, resolved with withParent HOC or useFormValue hook.
import React from 'react'
export const MyCustomInput = React.forwardRef((props, ref) => {
const { parent } = props
// Access the parent schema values
const parentValue1 = parent.parentValue1
const parentValue2 = parent.parentValue2
// render the input component
return (
<div>
<input type="text" />
</div>
)
}
export default MyCustomInputimport React from 'react'
export const MyCustomInput = React.forwardRef((props, ref) => {
const { document } = props
// Access the parent schema values
const parentValue1 = document.parentValue1
const parentValue2 = document.parentValue2
// render the input component
return (
<div>
<input type="text" />
</div>
)
}
export default MyCustomInputimport {withParent} from 'part:@sanity/form-builder'useFormValuehook.
useFormValuehook?
Was this answer helpful?
Sanity – Build the way you think, not the way your CMS thinks
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.