useField 发生错误 "无法读取 undefined 的属性 'active'"
作者: hieusmiths创建于 2021年1月11日更新于 2026年2月16日
你是提交一个 错误报告 还是一个 功能请求 ?
当前行为是什么?
对于懒加载的初始值字段,我使用 useField 来注册 API 加载后的字段。我的代码如下:
if (loading) return <Compo medias={some thing} /> Compo = (medias) => { useField("attachmentFile", { initialValue: medias }); return null; } 错误信息: final-form.es.js:181 Uncaught (in promise) TypeError: Cannot read property 'active' of undefined 在 publishFieldState (final-form.es.js:181) 处 在 notifyField (final-form.es.js:739) 处 在 notifyFieldListeners (final-form.es.js:750) 处 在 notify (final-form.es.js:1082) 处 在 afterPromise (final-form.es.js:712) 处 如果这是一个错误,请包括重现步骤和使用 Sandbox、Plunkr、WebpackBin 或 JSFiddle 示范问题的最小示例。
预期行为是什么?
Sandbox 链接 无
你的环境是什么? Ubuntu
其他信息
内容来源: final-form/react-final-form