最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Render prop messing up Next.js' hot reload - Stack Overflow

programmeradmin1浏览0评论

I have I component like this in a file:

export const ProfileForm: React.FC<ProfileFormProps> = ({
  isEditing,
  register,
  control,
  // more props
}) => {

And I'm passing it as a render prop to a component in another file:

<ItemEditForm
  renderForm={ProfileForm}
/>

//  renderForm: (props: RenderForm<TFormValues>) => React.ReactNode;
//   
//  {renderForm({
//    register,
//    control,
//    errors,
//   })
     

This works. However, I no longer get hot-reload in Next.js if I modify ProfileForm. But if I pass the component like this instead:

<ItemEditForm
  renderForm={(props: ProfileFormProps) => <ProfileForm {...props} />}
/>

I get the hot-reload back.

Why is this? Did I declare the render prop wrongly?

发布评论

评论列表(0)

  1. 暂无评论