如何将弹出组件导入 React-Native?

how to import popup component to React-Native?

我是 React-Native 的初学者,我想在我的应用程序中添加一个弹出窗口 window,我发现了这个:https://www.npmjs.com/package/react-native-popup 我迈出了第一步:

npm install react-native-popup --save

然后每当我使用此行将它导入我的项目并在我的 Android 模拟器上 运行 时:

import Popup from 'react-native-popup';

我收到红屏并出现此错误:

seems you're trying to access 'ReactNative.Component' from the 'react-native' package. Perhaps you meant to access 'React.Component' from the 'react' package instead? For example, instead of: import React, { Component, View} from 'react-native'; you should now do: import React, { Component } from 'react' import {View} from 'react-native';

虽然这是我实际做的,但这是我的代码:

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  TouchableHighlight,
  View
} from 'react-native';
import Popup from 'react-native-popup';

class AwesomeProject3 extends Component {

这不是你的错误,而是那个库 react-native-popup,它从 react-native 导入了 React,而且它确实被贬低了。

我会建议你使用 React-Native 的原始 ModalAlert 来代替。他们工作完美。