Search code examples
javascriptreact-nativeexpotoast

Why is my Expo app not sending the messages?


I have an application created with Expo and the wing which has a contact form from which to send inquiries.

I have started with the application already built, I am just setting my data. The problem is that the sent queries do not reach the mail that I have established in the configuration, in a file (config.php) so that the messages must arrive in smtp mode This is my server configuration:

$emailConfig = array(
'address' => 'xxxxxxx',
'password' => 'xxxx',
'name' => 'jose',
'smtp_host' => 'smtp.xxxx.es',
'smtp_port' => '587',
'smtp_encrypt' => 'tls'
);

The application, the debugging console shows me the following when I click SEND:

Toast is not defined
* application/components/PlaceFav.js:82:10 in render
- node_modules/react-native/node_modules/promise/setimmediate/core.js:37:11 in tryCallOne
- node_modules/react-native/node_modules/promise/setimmediate/core.js:123:14 in setImmediate$argument_0
- ... 8 more stack frames from framework internals

The file referenced by the console output is as follows, the line :

renderItem={({item, index}) =>

import React, {Component} from 'react';
import * as firebase from 'firebase';
import { NavigationActions, StackNavigator, withNavigation} from 'react-navigation';
import{AsyncStorage, TouchableOpacity, Dimensions, View, Image, ScrollView, FlatList} from 'react-native';
import Icon from 'react-native-vector-icons/SimpleLineIcons';
import { Container, Body, Thumbnail, Text, List, Right, ListItem} from 'native-base';
import ConfigApp from '../utils/ConfigApp';
import FavListEmpty from './FavListEmpty';
import Strings from '../utils/Strings';

var styles = require('../../assets/files/Styles');
var {height, width} = Dimensions.get('window');

class PlaceFav extends React.Component {

  constructor(props) {

    super(props);

    this.state = {
      places: []
    }

  }

  componentDidMount () {
    this.fetchPlaces();
  }

  PlaceDetails (item) {
    const navigateAction = NavigationActions.navigate({
      routeName: 'PlaceDetailsScreen',
      params: {item}
    });
    this.props.navigation.dispatch(navigateAction);
  }

  renderFooterPlaces = () => {
  const places = this.state.places
  if (places.length != 0) return null;


  return (
    <FavListEmpty/>
   );
};

removePlace = async (place_id) => {
try {

var user = firebase.auth().currentUser;
uid = user.uid;

const places = await AsyncStorage.getItem('places');
let placesFav = JSON.parse(places);
placesItems = placesFav.filter(function(e){ return e.place_id !== place_id && e.userId == uid })

await AsyncStorage.setItem('places', JSON.stringify(placesItems));

this.setState({ 
...this.state, 
places: placesItems || [] 
}); 

} catch(error) {

}}; 

  render () {

    return (

<List>

<ListItem itemDivider>
              <Text>{Strings.ST1}</Text>
            </ListItem>    

<FlatList
          data={this.state.places}
          refreshing="true"
          renderItem={({item, index}) =>

<ListItem style={{paddingLeft: 0, marginLeft: 0, backgroundColor:'#FFF', opacity: 1, borderColor: 'rgba(0,0,0,0.05)', borderBottomWidth: 1}}  onPress={() => this.PlaceDetails(item)} >
              <Thumbnail rounded size={80} source={{ uri: ConfigApp.URL+'images/'+item.place_image }} style={{paddingLeft: 10, marginLeft: 10}} />
              <Body style={{paddingLeft: 0, marginLeft: 0}}>
                <Text numberOfLines={2} style={{fontSize: 14, marginBottom: 3}}>
                {item.place_name}
                </Text>
              </Body>
              <Right>
              <TouchableOpacity onPress={this.removePlace.bind(this, item.place_id)} activeOpacity={1}>
                <Text note>
                <Icon name="close" style={{fontSize: 19}}/>
                </Text>
                </TouchableOpacity>

              </Right>
            </ListItem>

          
}
        keyExtractor={(item, index) => index.toString()}
        ListFooterComponent={this.renderFooterPlaces}


        /> 

</List>

    )
  }

    async fetchPlaces () {
      var user = firebase.auth().currentUser;
      uid = user.uid;

      let placesJSON= await AsyncStorage.getItem('places');
      let placesFav = JSON.parse(placesJSON);
      placesItems = placesFav.filter(function(e){
            return e.userId == uid
        })
      const placesArray = placesItems || [];
      this.setState({
        ...this.state,
        places: placesArray
      });
  }

}

export default withNavigation(PlaceFav);

I do not have much knowledge yet in React in Javascript and php, I do not know what this error means and I have searched for answers without success. I don't know if what I show is enough for you to help me


Solution

  • I finally discovered the mistake, a beginner's mistake I explain it for if another user happens the same as me.

    The problem was that I was not editing the Backend code. I mean that I am working on the project locally and the Backend is on a server. I modified the code in my local files, but it did not upload the updates to the server This was why the messages from the application were not sent

    I hope this can help someone else, and it makes me think that you have to check all the possible errors before looking for help and solution. Thanks to this wonderful site