[英]how to import popup component to React-Native?
I'm beginner in React-Native and I want to add a popup window to my app, I found this: https://www.npmjs.com/package/react-native-popup I made the first step: 我是React-Native的初学者,我想向我的应用添加一个弹出窗口,发现了这一点: https : //www.npmjs.com/package/react-native-popup我迈出了第一步:
npm install react-native-popup --save
then whenever I import it to my project using this line and run it on my Android emulator: 然后每当我使用此行将其导入到项目中并在Android模拟器上运行它时:
import Popup from 'react-native-popup';
I get a red screen with this error: 我出现此错误的红色屏幕:
seems you're trying to access 'ReactNative.Component' from the 'react-native' package.
似乎您正在尝试从“ react-native”包中访问“ ReactNative.Component”。 Perhaps you meant to access 'React.Component' from the 'react' package instead?
也许您是想从“反应”包中访问“ React.Component”? For example, instead of: import React, { Component, View} from 'react-native';
例如,而不是:从'react-native'导入React,{Component,View}; you should now do: import React, { Component } from 'react' import {View} from 'react-native';
您现在应该这样做:从'react'导入React,{组件}从'react-native'导入{View};
Although this is what I'm actually doing, here's my code: 尽管这是我实际上正在做的,但是这是我的代码:
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
TouchableHighlight,
View
} from 'react-native';
import Popup from 'react-native-popup';
class AwesomeProject3 extends Component {
It's not your error, it's that library, react-native-popup
, it imports React
from react-native
, and that is really depricated. 这不是您的错误,它是一个库
react-native-popup
,它从react-native
导入React
,这确实是不完整的。
I will suggest you to use React-Native's original Modal
and Alert
instead. 我建议您改用React-Native的原始
Modal
和Alert
。 They works perfect. 他们工作完美。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.