response-native-elements FormInput не может быть импортирован

Похоже, мне не разрешено импортировать FormInput из Reaction-native-элементов.

Я получил эту ошибку:

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, потому что, если я закомментирую две строки, он будет отображаться нормально.

2 ответа

Решение

FormInput существует только в версии React-Native-Elements версии 0.19.1.

Убедитесь, что вы правильно установили версию 0.19.1, используя код ниже в терминале,

npm -i react-native-elements@0.19.1

Здесь больше информации для 0.19.1 элементов, 0.19.1 Input

Тем не менее, вы также можете продолжать использовать версию 1.0.0 response-native-elements. Для 1.0.0 компонент ввода немного отличается. Вот ссылка на элементы ввода в React-Native, 1.0.0 Input

FormInput был изменен на Input начиная с версии 1.0.0-бета

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

это должно работать.

Больше информации здесь

Другие вопросы по тегам