byteburgers / react-native-autocomplete-input

Pure javascript autocomplete input for react-native
https://byteburgers.com/autocomplete
MIT License
820 stars 255 forks source link

On iOS 18.1 Simulator after typing the first letter in the input the app crashes #312

Open pierol opened 6 days ago

pierol commented 6 days ago

I'm using this component on:

Afeter typing the first letter from the keyboard the app crashes. If i test the same code on a real iPhone device but with iOS 16 it doesn't happen. The app crashes before fetching the url for getting the items, because it just happen after insert in the input the first letter.

https://github.com/user-attachments/assets/b2132eb4-fecd-450e-bb40-f2c7d29dd3d3

import React, { Component } from 'react';
import { StyleSheet, Text, TouchableOpacity, View, Platform } from 'react-native';
import { connect } from 'react-redux';
import Autocomplete from 'react-native-autocomplete-input';
import AppConfiguration from '../../config/AppConfiguration';
import { queryGiocatoreUpdate } from '../../actions';
import AutocompleteSuggestion from './AutocompleteSuggestion';

class AutocompleteGiocatore extends Component {
  constructor(props) {
    super(props);
    this.state = {
      utenti: []
    };
  }

  UNSAFE_componentWillReceiveProps(newProps) {
    const { queryGiocatore } = newProps.eisAppState;
    this.getSuggestions(queryGiocatore);
    if (!queryGiocatore || queryGiocatore.lenght <= 2) {
      this.setState({ utenti: [] });
    }
  }

  getSuggestions(query) {
    if (query.length > 2) {
      fetch(
        `${
          AppConfiguration.endPointBaseUrl
        }/utente/autocompletesocio?term=${query}`,
        {
          method: 'GET',
          headers: AppConfiguration.fetchHeaders(this.props.auth.token)
        }
      )
        .then(res => res.json())
        .then(json => {
          this.setState({ utenti: json });
        });
    }
  }

  renderSuggestion(e) {
    return <AutocompleteSuggestion utente={e.item} />;
  }

  render() {
    const { utenti } = this.state;
    const { queryGiocatore } = this.props.eisAppState;

    return (
      <View style={styles.container}>
        <View style={styles.descriptionContainer}>
          <Text style={styles.infoText}>
            Digita il nome di eventuali soci partecipanti
          </Text>
        </View>
        <View style={
            Platform.OS !== 'ios'
              ? styles.autocompleteContainerAndroid
              : styles.autocompleteContainerIos
          }>
        <Autocomplete
          autoCapitalize="none"
          autoCorrect={false}
          //containerStyle={styles.autocompleteContainer}
          listContainerStyle={styles.listContainer}
          data={utenti}
          value={queryGiocatore}
          onChangeText={text => this.props.queryGiocatoreUpdate(text)}
          placeholder="Digita il nome di eventuali soci partecipanti"
          flatListProps={{
            keyExtractor: (item,index) => item.IdUtente.toString(),
            renderItem: utente => this.renderSuggestion(utente),
          }}
        />
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    backgroundColor: '#F5FCFF',
    height: 100,
    paddingTop: 10,
    paddingBottom: 25,
    zIndex: 1000,
    marginLeft: 5,
    marginRight: 5
  },
  autocompleteContainerAndroid: {
    flex: 1,
    left: 0,
    position: 'absolute',
    right: 0,
    top: 35,
    zIndex: 1
  },
  autocompleteContainerIos: {

  },
  listContainer: {
    marginLeft: 10,
    marginRight: 10,
    paddingBottom: 10,
    paddingTop: 10,
    backgroundColor: '#F5FCFF',
    zIndex: 10000
  },
  autocompleteContainer: {
    marginLeft: 10,
    marginRight: 10,
    backgroundColor: '#FFFFFF'
  },
  itemText: {
    fontSize: 15,
    margin: 2
  },
  descriptionContainer: {
    // `backgroundColor` needs to be set otherwise the
    // autocomplete input will disappear on text input.
    backgroundColor: '#F5FCFF',
    marginBottom: 8
  },
  infoText: {
    textAlign: 'center'
  },
  titleText: {
    fontSize: 18,
    fontWeight: '500',
    marginBottom: 10,
    marginTop: 10,
    textAlign: 'center'
  },
  directorText: {
    color: 'grey',
    fontSize: 12,
    marginBottom: 10,
    textAlign: 'center'
  },
  openingText: {
    textAlign: 'center'
  }
});

const mapStateToProps = state => {
  const { eisAppState, auth } = state;
  return { eisAppState, auth };
};

export default connect(mapStateToProps, { queryGiocatoreUpdate })(
  AutocompleteGiocatore
);

This is the console log for the simulator:

errore  22:53:53.606769+0100    Expo Go 2024-11-25 22:53:53.606 [info][tid:com.facebook.react.runtime.JavaScript] fired
errore  22:53:54.269586+0100    Expo Go 2024-11-25 22:53:54.270 [info][tid:main][EXReactLogHandler.m:21] Module <EXScopedPermissions: 0x6000023db200> overrides <EXPermissionsService: 0x600000d72a60> as the module exported as .
errore  22:53:54.269670+0100    Expo Go 2024-11-25 22:53:54.270 [info][tid:main][EXReactLogHandler.m:21] Module <EXTaskManager: 0x6000019fc240> overrides <EXTaskManager: 0x600001a13980> as the module exported as ExpoTaskManager.
errore  22:53:54.269726+0100    Expo Go 2024-11-25 22:53:54.270 [info][tid:main][EXReactLogHandler.m:21] Module <EXScopedNotificationsEmitter: 0x600001a26540> overrides <EXNotificationsEmitter: 0x600000d71a10> as the module exported as ExpoNotificationsEmitter.
errore  22:53:54.269793+0100    Expo Go 2024-11-25 22:53:54.270 [info][tid:main][EXReactLogHandler.m:21] Module <EXScopedNotificationsHandlerModule: 0x6000019ff180> overrides <EXNotificationsHandlerModule: 0x600001a12400> as the module exported as ExpoNotificationsHandlerModule.
errore  22:53:54.269865+0100    Expo Go 2024-11-25 22:53:54.270 [info][tid:main][EXReactLogHandler.m:21] Module <EXScopedNotificationSchedulerModule: 0x600000d71c80> overrides <EXNotificationSchedulerModule: 0x6000003f8e80> as the module exported as ExpoNotificationScheduler.
errore  22:53:54.269927+0100    Expo Go 2024-11-25 22:53:54.270 [info][tid:main][EXReactLogHandler.m:21] Module <EXScopedNotificationPresentationModule: 0x6000019fd7c0> overrides <EXNotificationPresentationModule: 0x600000d70ea0> as the module exported as ExpoNotificationPresenter.
errore  22:53:54.269973+0100    Expo Go 2024-11-25 22:53:54.270 [info][tid:main][EXReactLogHandler.m:21] Module <EXScopedNotificationCategoriesModule: 0x600000464a00> overrides <EXNotificationCategoriesModule: 0x6000003f9f00> as the module exported as ExpoNotificationCategoriesModule.
errore  22:53:54.270558+0100    Expo Go 2024-11-25 22:53:54.271 [info][tid:main][EXReactLogHandler.m:21] Module <EXScopedServerRegistrationModule: 0x600000474700> overrides <EXServerRegistrationModule: 0x6000003fa2a0> as the module exported as NotificationsServerRegistrationModule.
errore  22:53:54.790693+0100    Expo Go nw_socket_handle_socket_event [C80:1] Socket SO_ERROR [61: Connection refused]
errore  22:53:54.790767+0100    Expo Go nw_endpoint_flow_failed_with_error [C80 IPv4#80375f3b:8097 in_progress socket-flow (satisfied (Path is satisfied), interface: lo0)] already failing, returning
errore  22:53:54.791037+0100    Expo Go nw_connection_get_connected_socket_block_invoke [C80] Client called nw_connection_get_connected_socket on unconnected nw_connection
errore  22:53:54.791064+0100    Expo Go TCP Conn 0x60000339e580 Failed : error 0:61 [61]
errore  22:53:54.791294+0100    Expo Go nw_connection_copy_connected_local_endpoint_block_invoke [C80] Client called nw_connection_copy_connected_local_endpoint on unconnected nw_connection
errore  22:53:54.791310+0100    Expo Go nw_connection_copy_connected_remote_endpoint_block_invoke [C80] Client called nw_connection_copy_connected_remote_endpoint on unconnected nw_connection
errore  22:53:54.833825+0100    Expo Go 2024-11-25 22:53:54.834 [info][tid:com.facebook.react.runtime.JavaScript] Bridgeless mode is enabled
errore  22:53:54.882963+0100    Expo Go Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
errore  22:53:54.882997+0100    Expo Go Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
errore  22:53:54.883166+0100    Expo Go Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
errore  22:53:54.883188+0100    Expo Go Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
errore  22:53:54.883337+0100    Expo Go Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
errore  22:53:54.883357+0100    Expo Go Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
errore  22:53:54.884352+0100    Expo Go Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
errore  22:53:54.884371+0100    Expo Go Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
errore  22:53:54.884399+0100    Expo Go Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
errore  22:53:54.884599+0100    Expo Go Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
errore  22:53:54.884624+0100    Expo Go Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
errore  22:53:54.884780+0100    Expo Go Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
errore  22:53:54.884798+0100    Expo Go Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
errore  22:53:55.593152+0100    Expo Go 2024-11-25 22:53:55.593 [warn][tid:com.facebook.react.runtime.JavaScript] expo-notifications: Push notifications (remote notifications) functionality provided by expo-notifications will be removed from Expo Go in SDK 53. Instead, use a development build. Read more at https://docs.expo.dev/develop/development-builds/introduction/.
errore  22:53:55.599788+0100    Expo Go 2024-11-25 22:53:55.600 [warn][tid:com.facebook.react.runtime.JavaScript] `expo-notifications` functionality is not fully supported in Expo Go:
We recommend you instead use a development build to avoid limitations. Learn more: https://expo.fyi/dev-client.
errore  22:53:55.631984+0100    Expo Go 2024-11-25 22:53:55.632 [info][tid:com.facebook.react.runtime.JavaScript][RCTPerformanceLogger.mm:78] Unbalanced calls start/end for tag 20
errore  22:53:55.632044+0100    Expo Go 2024-11-25 22:53:55.632 [info][tid:com.facebook.react.runtime.JavaScript][RCTPerformanceLogger.mm:78] Unbalanced calls start/end for tag 19
errore  22:53:55.635711+0100    Expo Go 2024-11-25 22:53:55.636 [info][tid:com.facebook.react.runtime.JavaScript] Running "main" with {"rootTag":111,"initialProps":{"exp":{"manifestString":"{\"runtimeVersion\":\"exposdk:52.0.0\",\"isVerified\":true,\"metadata\":{},\"extra\":{\"eas\":{\"projectId\":\"95441ac0-0f57-11e8-b48c-819261f77ec6\"},\"scopeKey\":\"@ingegnosi\\/eisapp\",\"expoClient\":{\"scheme\":\"eisapp\",\"slug\":\"eisapp\",\"splash\":{\"resizeMode\":\"contain\",\"backgroundColor\":\"#0066ff\",\"image\":\".\\/assets\\/images\\/eis-blue-splash.png\",\"imageUrl\":\"http:\\/\\/192.168.1.126:8081\\/assets\\/.\\/assets\\/images\\/eis-blue-splash.png\"},\"plugins\":[\"expo-font\"],\"newArchEnabled\":true,\"android\":{\"package\":\"com.ingegnosi.eisapp\",\"permissions\":[],\"useNextNotificationsApi\":true,\"googleServicesFile\":\"{\\n  \\\"project_info\\\": {\\n    \\\"project_number\\\": \\\"179133886608\\\",\\n    \\\"firebase_url\\\": \\\"https:\\/\\/eis-app-31b16.firebaseio.com\\\",\\n    \\\"project_id\\\": \\\"eis-app-31b16\\\",\\n <…>
guasto  22:53:55.751218+0100    Expo Go GSFont: "Ionicons" already exists.
errore  22:53:55.979635+0100    Expo Go 2024-11-25 22:53:55.980 [info][tid:com.facebook.react.runtime.JavaScript] Must use physical device for Push Notifications
errore  22:53:56.451047+0100    Expo Go 0x12b14cf80 - GPUProcessProxy::gpuProcessExited: reason=IdleExit
errore  22:53:56.451075+0100    Expo Go 0x12b018680 - [PID=0] WebProcessProxy::gpuProcessExited: reason=IdleExit
pierol commented 4 days ago

Sorry, i think that the problem is about the focus. If i get the focus on the textinput and i type le letter "r" Expo Go gets this letter as the reload app command, i don't know why this happen.