react-native-elements FormInput 无法导入
react-native-elements FormInput cannot be imported
似乎不允许我从 react-native-elements 导入 FormInput。
我收到这个错误:
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: 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 `LoginForm`.
我的代码如下:
import React, { Component } from 'react'
import { Text, View } from 'react-native'
import { FormInput, Button } from 'react-native-elements'
export default class LoginForm extends Component {
render() {
return (
<View>
<FormInput value="" placeholder="Enter email"></FormInput>
<FormInput valye="" placeholder="Enter password"></FormInput>
<Button title="Login" backgroundColor="red"></Button>
</View>
)
}
}
我看不出我的做法与官方有何不同doc。我知道 FormInput 是问题所在,因为如果我注释掉这两行,那么它就可以正常显示。
FormInput 仅存在于 0.19.1 版本的 React-Native-Elements 中。
请确保您已在终端中使用以下代码正确安装版本 0.19.1,
npm -i react-native-elements@0.19.1
这里是 0.19.1 元素的更多信息,
0.19.1 Input
不过,你也可以继续使用1.0.0版本的react-native-elements。
对于1.0.0,输入组件有点不同。
这是关于 React-Native 中输入元素的 link,
1.0.0 Input
从 v1.0.0-beta 开始,FormInput
已更改为 Input
import React, { Component } from 'react'
import { Text, View } from 'react-native'
import { Input, Button } from 'react-native-elements'
export default class LoginForm extends Component {
render() {
return (
<View>
<Input value="" placeholder="Enter email"></Input>
<Input valye="" placeholder="Enter password"></Input>
<Button title="Login" backgroundColor="red"></Button>
</View>
)
}
}
这应该有效。
更多信息here
似乎不允许我从 react-native-elements 导入 FormInput。
我收到这个错误:
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: 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 `LoginForm`.
我的代码如下:
import React, { Component } from 'react'
import { Text, View } from 'react-native'
import { FormInput, Button } from 'react-native-elements'
export default class LoginForm extends Component {
render() {
return (
<View>
<FormInput value="" placeholder="Enter email"></FormInput>
<FormInput valye="" placeholder="Enter password"></FormInput>
<Button title="Login" backgroundColor="red"></Button>
</View>
)
}
}
我看不出我的做法与官方有何不同doc。我知道 FormInput 是问题所在,因为如果我注释掉这两行,那么它就可以正常显示。
FormInput 仅存在于 0.19.1 版本的 React-Native-Elements 中。
请确保您已在终端中使用以下代码正确安装版本 0.19.1,
npm -i react-native-elements@0.19.1
这里是 0.19.1 元素的更多信息, 0.19.1 Input
不过,你也可以继续使用1.0.0版本的react-native-elements。 对于1.0.0,输入组件有点不同。 这是关于 React-Native 中输入元素的 link, 1.0.0 Input
FormInput
已更改为 Input
import React, { Component } from 'react'
import { Text, View } from 'react-native'
import { Input, Button } from 'react-native-elements'
export default class LoginForm extends Component {
render() {
return (
<View>
<Input value="" placeholder="Enter email"></Input>
<Input valye="" placeholder="Enter password"></Input>
<Button title="Login" backgroundColor="red"></Button>
</View>
)
}
}
这应该有效。
更多信息here