0

好像我不允许从 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>
    )
  }
}

我看不出我在做什么与官方文档不同。我知道 FormInput 是问题所在,因为如果我注释掉这两行,那么它会呈现得很好。

4

2 回答 2

1

FormInput仅存在于0.19.1版本的 React-Native-Elements 中。

确保您已在终端中使用以下代码正确安装了0.19.1版本,

npm -i react-native-elements@0.19.1

这是0.19.1元素的更多信息, 0.19.1 输入

但是,您也可以继续使用 1.0.0 版本的 react-native-elements。对于1.0.0,输入组件略有不同。这是有关 React-Native 1.0.0 Input中输入元素的链接

于 2019-02-19T01:08:28.823 回答
0

FormInputInput从 v1.0.0-beta 起已更改为

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>
    )
  }
}

这应该有效。

更多信息在这里

于 2019-02-19T01:16:31.083 回答