How to fix this error 'undefined is not an object'?

how to fix your connection is not private
loading error code
aw snap error on samsung tablet
your connection is not private net::err_cert_authority_invalid
loading error page
aw snap message android
your connection is not secure chrome
your connection is not private chrome bypass

The output error like this:

TypeError: TypeError: undefined is not an object (evaluating '_this.state.userInfo.picture.data')

there I just want passing data from facebook into my view in react native . it says undefined is not an object, how to fix this ?

Here is the HomeScreen component's code:

import React, { Component } from 'react';
import { Text, TouchableOpacity, ScrollView, View, StyleSheet, Button, Alert, Image } from 'react-native';
import Expo, { Constants } from 'expo';

export default class HomeScreen extends Component {

    constructor(props){
        super(props);
        this.state = { userInfo: null }
    }

    async logInFB() {
        try {
          const {
            type,
            token,
            expires,
            permissions,
            declinedPermissions,
          } = await Expo.Facebook.logInWithReadPermissionsAsync('214751749451960', {
            permissions: ['public_profile'],
          });
          if (type === 'success') {
            // Get the user's name using Facebook's Graph API
            const response = await fetch(`https://graph.facebook.com/me?access_token=${token}&fields=id.name.picture.type(large)`);
            const userInfo = await response.json();
            this.setState({ userInfo });
            Alert.alert('Logged in!', `Hi ${(await response.json()).name}!`);
          } else {
            // type === 'cancel'
          }
        } catch ({ message }) {
          alert(`Facebook Login Error: ${message}`);
        }
    }

    _renderUserInfo = () => {
        return(
            <View style={{ alignItems:'center' }}>
                <Image
                    source={{ uri: this.state.userInfo.picture.data.url}}
                    style={{width:100, height:100, borderRadius:50}}
                />
                <Text style={{ fontSize:20 }}>
                    { this.state.userInfo.name }
                </Text>
                <Text>ID: { this.state.userInfo.id }</Text>
            </View>
        );
    }


    render(){
        return(
            <View style={styles.container}>
                <Text>welcome to my apps!</Text>
                { !this.state.userInfo ? (<Button title="Connect with facebook" onPress={this.logInFB.bind(this)}/>) : (this._renderUserInfo())}
            </View>
        );
    }
}

Here is the styling (They are both on the same file):

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
  },
  paragraph: {
    margin: 24,
    fontSize: 18,
    fontWeight: 'bold',
    textAlign: 'center',
    color: '#34495e',
  },
});

Thanks in advance :)

Try declare your userInfo in your state this way.

constructor(props){
        super(props);
        this.state = { userInfo:{} }
    }

It's possible that your "this.state.userInfo" in this line

source={{ uri: this.state.userInfo.picture.data.url}}

is still null, hence, null.picture.data.url where null is not an object.

Your Connection Is Not Private, Why does Chrome keep saying your connection is not private? Consider what you are doing on your PC when the error message appears, write down what program is causing the error, what version of the program you are running, and what is the program trying to do when the error occurs. 3 Scan your computer with your anti-virus application and remove any threats it detects.

Instead of

import Expo, { Constants } from 'expo';

Try

import { Facebook, Constants } from 'expo';

Then change

await Expo.Facebook.logInWithReadPermissionsAsync

to

await Facebook.logInWithReadPermissionsAsync

see https://forums.expo.io/t/import-expo-from-expo-has-been-deprecated/15799

ERR_CONNECTION_RESET: How to fix the Chrome connection , ” error is that a proxy server has been defined in the internet settings and this is blocking the connection setup. This can be entered automatically by plugins or add-ons that you have added to your browser. Your device is missing important security and quality fixes | How to fix Windows 10 update errors - Duration: 3:01. Exploring Life 162,999 views

From the code it's very clear that this.state.userInfo.picture.data.url chain traversing has undefined somewhere in between.

I'm not giving the exact solution but a suggestion to avoid this type of errors known as null pointer exceptions .

Please use some simple util library like idx for traversing properties on objects.

// Using regular JavaScript 

getSourceURL = () => {
  if( this 
    && this.state 
    && this.state.userInfo 
    && this.state.userInfo.picture 
    && this.state.userInfo.picture.data 
    && this.state.userInfo.picture.data.url) {
    return this.state.userInfo.picture.data.url;
  } 
}

You can achieve the same using idx as below

// Using idx 

getSourceURL = () => {
  if( idx(this, _ => _.state.userInfo.picture.data.url )) {
    return this.state.userInfo.picture.data.url;
  }
}

Fix file download errors - Google Chrome Help, Fix file download errors. If you get an error message on Chrome when you try to download apps, themes, extensions, or other files, try these fixes. Hello Fellow Gamer! Thank you for providing that insight for us! My next recommendation would actually be to remove your account from your console, and then see if you can update your password on your account.

Try not to set state to null anyway! You can initialize like this :

 userInfo : {
    picture: { }
 }

According to component lifecycles constructor will execute first. Your task is asynchronous so the state will stay null till data is retrieved from server.

How to Fix PC Errors in Windows, You can scan and repair Windows with system tools for free. Learn how to remove computer Duration: 2:34 Posted: 27 Mar 2013 wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, volunteer authors worked to edit and improve it over time. The wikiHow Tech Team also followed the article's instructions and verified that they work. This article has been viewed 14,799 times. Learn

Error 101 - how to fix error, This error may be fixed with special software that repairs the registry and tunes up system settings to restore stability. The article provides details on the error  Repair DirectX This problem can usually be caused by a corrupted DirectX installation. While it is difficult to uninstall DirectX from your computer what you can do instead is to repair it.

How to fix Error 0xA: IRQL_not_less_or_equal, The error, which usually comes with the 101 code, is particularly common on Chrome (Google's browser), but Firefox, Internet Explorer, etc. also 

Fix Windows Update errors, This error means that something may be wrong with a device driver, your device's memory, or antivirus software on your device. Here are some 

Comments
  • i already using this .bind into my buttonevent, but still not work for me , onPress={this.logInFB.bind(this)}
  • Try logging the userInfo object, and checking if it has a property called 'picture'. It's possible the Facebook isn't giving you that property if a user has no picture
  • please help.. upp
  • plus 1 introducing idx.