DEV Community

ivkeMilioner
ivkeMilioner

Posted on • Updated on

Work on web some function do not work in device

Mine react native app work in the web browser (react native + expo) but in android device, fetchCopiedText returns "null" and convertStr breaking app. I can see any error output to find what breaks the code. In a web browser, everything works fine.

```import React, { useState } from "react";
import { SafeAreaView, StyleSheet, TextInput, Button } from "react-native";

import Clipboard from "expo-clipboard";

const Cyr = () => {
const [text, setText] = useState("");

const copyToClipboard = () => {
Clipboard.setString(text);
console.log(text);
};

const fetchCopiedText = async () => {
const text = await Clipboard.getStringAsync();
setText(text);
};

const clearAll = () => {
setText("");
};
const convertStr = () => {
setText(
text
.replace(/x/g, "xx")
.replace(/y/g, "yy")
.replace(/t/g, "tt")
.replace(/.([^\s\d])/g, ". $1")
.replace(/\,([^\s\d])/g, ", $1")
);
};

return (



style={styles.input}
onChange={(e) => setText(e.target.value)}
value={text}
multiline
selectable
/>



);
};

const styles = StyleSheet.create({
input: {
height: 300,
width: 400,
margin: 12,
borderWidth: 1,
},
});

export default Cyr; ```

Top comments (0)