Formic Component causing 'Error:Element type is invalid'. Unable to determine the cause
Formic Component causing 'Error:Element type is invalid'. Unable to determine the cause
我正在尝试在我的 React Native App
中使用 Formic 构建一个表单
相关代码如下:
import other stuff
import {Formic} from 'formic'
const ReviewForm = () => (
<View style={globalStyles.container}>
<Formic >
<Text>Formic Content</Text>
</Formic>
</View>
)
export default ReviewForm
这样做会导致以下错误:
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s%s, undefined, You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of 'ReviewForm'.
我尝试了各种可能导致错误的可能性。
如果我注释掉 标签,即
,结果不会发生
const ReviewForm = () => (
<View style={globalStyles.container}>
{/*<Formic > */}
<Text>Formic Content</Text>
{/*</Formic>*/}
</View>
)
这很好用。
这可能是什么原因造成的?能否请你帮忙。
package.json 中的依赖项:*
"dependencies": {
"@expo-google-fonts/inter": "^0.1.0",
"@expo-google-fonts/lobster": "^0.1.0",
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/drawer": "^5.9.0",
"@react-navigation/native": "^5.7.3",
"@react-navigation/stack": "^5.9.0",
"expo": "~38.0.8",
"expo-font": "~8.2.1",
"expo-status-bar": "^1.0.2",
"formic": "0.0.10",
"install": "^0.13.0",
"node-fetch": "^2.6.1",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "https://github.com/expo/react-native/archive
/sdk-38.0.2.tar.gz",
"react-native-gesture-handler": "~1.6.0",
"react-native-paper": "4.0.0-alpha.1",
"react-native-reanimated": "~1.9.0",
"react-native-safe-area-context": "^3.1.7",
"react-native-screens": "^2.10.1",
"react-native-web": "~0.11.7",
"react-navigation": "^4.4.0",
"react-navigation-stack": "^2.8.2"
},
我认为您要找的是 Formik
而不是 Formic
。
这就是您要找的人 -> https://github.com/formium/formik
我正在尝试在我的 React Native App
中使用 Formic 构建一个表单相关代码如下:
import other stuff
import {Formic} from 'formic'
const ReviewForm = () => (
<View style={globalStyles.container}>
<Formic >
<Text>Formic Content</Text>
</Formic>
</View>
)
export default ReviewForm
这样做会导致以下错误:
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s%s, undefined, You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of 'ReviewForm'.
我尝试了各种可能导致错误的可能性。 如果我注释掉 标签,即
,结果不会发生const ReviewForm = () => (
<View style={globalStyles.container}>
{/*<Formic > */}
<Text>Formic Content</Text>
{/*</Formic>*/}
</View>
)
这很好用。
这可能是什么原因造成的?能否请你帮忙。 package.json 中的依赖项:*
"dependencies": {
"@expo-google-fonts/inter": "^0.1.0",
"@expo-google-fonts/lobster": "^0.1.0",
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/drawer": "^5.9.0",
"@react-navigation/native": "^5.7.3",
"@react-navigation/stack": "^5.9.0",
"expo": "~38.0.8",
"expo-font": "~8.2.1",
"expo-status-bar": "^1.0.2",
"formic": "0.0.10",
"install": "^0.13.0",
"node-fetch": "^2.6.1",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "https://github.com/expo/react-native/archive
/sdk-38.0.2.tar.gz",
"react-native-gesture-handler": "~1.6.0",
"react-native-paper": "4.0.0-alpha.1",
"react-native-reanimated": "~1.9.0",
"react-native-safe-area-context": "^3.1.7",
"react-native-screens": "^2.10.1",
"react-native-web": "~0.11.7",
"react-navigation": "^4.4.0",
"react-navigation-stack": "^2.8.2"
},
我认为您要找的是 Formik
而不是 Formic
。
这就是您要找的人 -> https://github.com/formium/formik