Gustash / react-native-image-keyboard

React Native TextInput expansion to enable media input.
MIT License
147 stars 14 forks source link

_onImageChange Callback Is Not Working Properly In Expo Go #44

Closed rkcollabro closed 7 months ago

rkcollabro commented 7 months ago

Version Info

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',
  },
});
Gustash commented 7 months ago

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.