Getting "TypeError: undefined is not an object" in an Expo React Native project when trying to create a custom "react-hook-form" input component

Getting "TypeError: undefined is not an object" in an Expo React Native project when trying to create a custom "react-hook-form" input component

我正在尝试创建一个可重复使用的组件并在我们所有的屏幕中使用它来代替默认的 TextInput 组件。在这个新的 CustomTextInput.js 组件中,我将主要的可配置组件导出为默认值,它包装在 react-hook-form 库提供的 Controller 组件中。然后,每当我创建 CustomTextInput 组件的实例时,我都应该从父组件传递 control 配置对象。

除了默认导出外,我还导出了该 CustomTextInput 组件的一些预配置变体。我成功地导出和使用了 EmailInputPasswordInput 配置,但是每当我尝试使用我的 CalendarInputLocationInput 个组件。尽管我可以通过从 CustomTextInput.js.

的默认导出中通过主组件传递所有配置来手动创建它们

更具体地说,当我尝试显示 CalendarInputLocationInput:

时收到此错误消息
TypeError: undefined is not an object (evaluating '_ref21$reValidateMode.isReValidateOnBlur')

我在 Expo Snack 中重现了这个错误,代码的基本部分可以在这个 URL 中找到: https://snack.expo.io/@sepsol/custom-text-input-error

如何通过成功显示从 CustomTextInput.js 组件导出的 CalendarInputLocationInput 来绕过此错误并解决此问题?

感谢 @leapful 我能够解决这个问题。这是我的错字:

CalendarInput 和 LocationInput 当前使用了错误的 props 参数。应该是:

export function CalendarInput({ control, ... }) {} 

而不是

export function CalendarInput(control, ...)