javascript - 为什么我的 Expo 应用没有发送消息?

标签 javascript react-native expo toast

我有一个用 Expo 和翼创建的应用程序,它有一个联系表格,可以从中发送查询。
我已经开始使用已经构建的应用程序,我只是在设置我的数据。
问题是发送的查询没有到达我在配置中建立的邮件,在一个文件 (config.php) 中,因此消息必须以 smtp 模式到达
这是我的服务器配置:

$emailConfig = array(
'address' => 'xxxxxxx',
'password' => 'xxxx',
'name' => 'jose',
'smtp_host' => 'smtp.xxxx.es',
'smtp_port' => '587',
'smtp_encrypt' => 'tls'
);
当我单击 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
控制台输出引用的文件如下,行:
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);

我在 Javascript 和 php 中的 React 方面还没有太多知识,我不知道这个错误意味着什么,我已经搜索了答案但没有成功。
我不知道我展示的东西是否足以让你帮助我

最佳答案

我终于发现了错误,初学者的错误
如果另一个用户和我发生同样的情况,我会解释一下。
问题是我没有编辑后端代码。我的意思是我在本地处理项目,后端在服务器上。
我修改了本地文件中的代码,但它没有将更新上传到服务器
这就是未发送来自应用程序的消息的原因
我希望这可以帮助其他人,这让我觉得您必须在寻求帮助和解决方案之前检查所有可能的错误。
感谢这个精彩的网站

关于javascript - 为什么我的 Expo 应用没有发送消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66569565/

相关文章:

javascript - Javascript 中的拆分函数并将其分配给变量会产生不同的结果

javascript - 如何在javascript中对值进行平方和求和

css - react native : Dynamically change style with AsyncStorage and States

reactjs - 为什么在 React Native 中我的页面转换之前有一个白色的 "loading screen"?

react-native - 如何正确使用 Expo.DocumentPicker.getDocumentAsync。 [博览会] [ReactNative]

android - react native : Generating apk file

javascript - 使外部网页认为它在iframe中是完整尺寸

android - USB摄像头连接到安卓手机

android - 相机未运行

javascript - event.returnValue=false 的问题;在js中