Hai i am trying to show alert message, i tried different ways like alert,AlertIOS,Alert.alert
AlertIOS is working in IPhone but not working in android and alert also same
In Docs i saw that Alert.alert will work for both Android an IOS,But i got an error like undefined is not an object(evaluating 'Alert.alert')
I wrote like this:
Alert.alert('Alert', 'email is not valid, Please enter correct email', [{text: 'Ok'}]);
I got an error like this:
Any one give suggestions that how to show the alert in Android and IOS in react-native
Any help much appreciated
Are you sure you are including it from the correct path?
I get the same error when I imported Alert from react library and NOT react-native.
so the working thingie is:
import React, { Component } from 'react';
import { View, Alert } from 'react-native';
and the non-working one was:
import React, { Component, Alert } from 'react';
import { View } from 'react-native';
I think you forget to import Alert from react-native
import { Alert } from 'react-native';
and then you can show Alert like this
Alert.alert("Alert message");
We just need to import it correctly:
import { Alert } from 'react-native';
Then use it in your project as written in your code and it will work for both platforms :
Alert.alert('Alert', 'email is not valid, Please enter correct email', [{text: 'Ok'}]);
refer: https://facebook.github.io/react-native/docs/alert
Related
Hell, I'm trying to create a tab bar in my react native app, but after importing it, it appears it's always undefined. Has this component been deprecated? I still see it listed in the docs. https://facebook.github.io/react-native/docs/tabbarios.html
import React, { Component } from 'react';
import {
TabBarIOS
} from 'react-native';
export default class App extends Component {
render() {
return (
<TabBarIOS/>
);
}
}
I'm using react-native 0.59.3
Looks like this has been removed as part of a core cleanup effort. There doesn't appear to be any native alternative that also behaves correctly on tvos.
https://github.com/facebook/react-native/commit/02697291ff41ddfac5b85d886e9cafa0261c8b98
I've gone ahead and extracted TabBarIOS out into a native module for anyone looking for this.
https://github.com/modavi/NativeIOS
install instructions:
npm install git+https://github.com/modavi/NativeIOS#master
react-native link native-ios
I am using react-native with native-base theme. Now I want to use react-native-share package. But I need to use Button from both package but I got duplicate identifier error.
import Share, { ShareSheet, Button } from 'react-native-share';
import { Button } from 'native-base';
May I know how to declare another button from react-native-share?
Please try use:
Import { Button as Btn } from 'native-base'
This should resolve your problem.
I'm trying to extend the built in react native TextInput component with a method to return the text selection rectangles for a given range. I followed this pattern here but I'm stuck at this step
import React, { Component } from 'react';
import {AppRegistry, StyleSheet, Text, View, NativeModules } from 'react-native';
var TextViewManager = NativeModules.TextViewManager;
TextViewManager is always null. Does anyone know why or how to get access to TextViewManager so I can call the method I've added to it?
I've tried accessing other managers (eg. WebViewManager) in the same way and it's worked a treat. It just seems like TextViewManager is a special case.
Ok I got itworking and it was because I didn't run react-native run-ios after changing my TextViewManager category source in Xcode. I mistakingly thought react-native log-ios built, installed and logged but it only logs.
I encountered a problem that import React. This is my error
Maybe it is a normal problem and I also find some ways to solve the problem on Google. I can't solve problem now.Because I think I already has changed it.This is my code
Thanks for your help
Try Following
import React, { Component } from 'react';
import { View } from 'react-native';
Try using
import * as React from 'react';
class MyProject extends React.Component ...
After upgrading my project to React-Native 0.26, the app crashing with the following error :
"Super expression must either be null or a function, not undefined"
It crashes in the Switch.js file, which belongs to the React-Native-Material-Kit package.
Ahh, it's because React-Native is moving fast! Too fast in my option. In 25 we saw this warning:
Deprecations
Requiring React API from react-native is now deprecated - 2eafcd4 0b534d1
Instead of:
import React, { Component, View } from 'react-native';
you should now:
import React, { Component } from 'react';
import { View } from 'react-native';
And just one release later in 26 this is now a breaking change
You can try this codemod if you dare. I'm just doing a manual change.