He creado una aplicación en la que quiero compartir un componente como una imagen. Lo estoy haciendo así.
const shareImageHandler = async () => { try { const uri = await captureRef(containerRef, { quality: 1, format: "jpg", }); await Sharing.shareAsync(uri); console.log("action succeed"); } catch (error) { console.log("something went wrong!"); }};
Pero estoy recibiendo este error.
[TypeError: undefined is not an object (evaluating '_expoSharing.default.shareAsync')]
el componente que quiero compartir como imagen.
<ImageBackground ref={containerRef} source={{ uri: imgUrl ?? img() }} resizeMode="cover" style={styles.bgImg} > <View style={{ width: "100%", height: "100%", position: "absolute", top: 0, left: 0, backgroundColor: "rgba(0,0,0,.7)", }} /> <View style={styles.contentContainer}> <Text style={styles.quote}>“ {content} ”</Text> <Text style={styles.author}>—{data}</Text> </View> </ImageBackground>He intentado muchas soluciones, pero nadie hizo el truco.
Nota: puedo guardar el componente como una imagen en la galería con éxito, es solo una nota al margen.
Esta aplicación se utilizará únicamente para dispositivos Android.
Gracias de antemano.
Debes estar importando mal la lib, a mi me paso lo mismo, estaba importando asi:
import Sharing from 'expo-sharing';pero la forma correcta es esta:
import * as Sharing from 'expo-sharing';