DEV Community

ivkeMilioner
ivkeMilioner

Posted on • Edited on

3 3

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; ```

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More