import { useFormContext, useWatch } from 'react-hook-form';

// A raw field has no input and never calls onChange (see Group::field()'s
// docblock server-side), so it doesn't need createFieldControl's Controller
// wiring — just watch its static default value.
export function RawField( { field } ) {
	const { control } = useFormContext();
	const value = useWatch( { name: field.id, control } );

	return <div dangerouslySetInnerHTML={ { __html: value ?? '' } } />;
}
