react-native-image-keyboard icon indicating copy to clipboard operation
react-native-image-keyboard copied to clipboard

_onImageChange Callback Is Not Working Properly In Expo Go

Open rkcollabro opened this issue 2 years ago • 1 comments

Version Info

  • react 18.2.0
  • react-native 0.72.6
  • react-native-image-keyboard 2.2.1
  • expo 49.0.6
  • Phone is Android Redmi Note 5

Problem

The onImageChange callback does not appear to be working as advertised in the README. By "not working", I mean the callback does not execute whatsoever, at least when called as onImageChange={_onImageChange}. I instead get the message "Expo Go doesn't support image insertion here".

The callback does seem to be recognized because the signature is shown when hovering over the onImageChange callback, which leads me to believe that the TextInputProps extend had succeeded.

I am using a newer react native version so I have not done any of the linking steps as required for RN <=0.60.

Sample Code

See this Expo snack and try running on the Android device to see that the callback does not execute when a .gif is selected.

Code is also here:

import { useState } from 'react';
import { Text, TextInput, SafeAreaView, StyleSheet } from 'react-native';

export default function App() {
  const [debug, setDebug] = useState('No image change detected yet :(');
  const [message, setMessage] = useState('');

  const _onImageChange = (event) => {
    setDebug("Can detect image change!");
    const {uri, linkUri, mime, data} = event.nativeEvent;
  }

  return (
    <SafeAreaView style={styles.container}>
      <Text>{debug}</Text>
      <TextInput
          value={message}
          onChangeText={setMessage}
          placeholder={'Comments?'}
          style={styles.input}
          onImageChange={_onImageChange}
      />
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
  input: {
    width: 250,
    height: 44,
    borderRadius: 10,
    padding: 10,
    marginTop: 20,
    marginBottom: 10,
    backgroundColor: 'paleturquoise',
  },
});

rkcollabro avatar Jan 28 '24 01:01 rkcollabro

Expo Go doesn't support native modules not bundled in with Expo. You need your own native project that can link native modules for this to work.

Gustash avatar Jan 29 '24 07:01 Gustash