我使用react hook表单输入文本,如下所示
<div className='mb-4'>
<label htmlFor='desc'>Description</label>
<TipTap
// iwant to pass the ...regiseter props here
/>
<textarea
className='w-full'
id='desc'
autoFocus
{...register('desc', {
required: 'Please enter description',
})}
/>
{errors.desc && (
<div className='text-red-500'>{errors.desc.message}</div>
)}
</div>
这是我的Tiptap组件
const TipTap = () => {
const tipTapEditor = useEditor({
extensions: [StarterKit],
content: ``,
onUpdate: ({ editor }: any) => {
const html = editor.getHTML();
console.log(html);
},
});
return (
<div>
<MenuBar editor={tipTapEditor} />
<EditorContent editor={tipTapEditor} />
</div>
);
};
我想使用Tiptap编辑器如何将{... register}作为道具传递给TitaTap组件
1条答案
按热度按时间uqzxnwby1#
我建议使用组件或来自RHF的useController挂钩。
在tiptap组件中,