React native 在web上工作某些功能在设备中不工作

React native 在web上工作某些功能在设备中不工作,react-native,React Native,Mine react本机应用程序在web浏览器(react native+expo)中工作,但在android设备中,fetchCopiedText返回“null”和convertStr应用程序。我可以看到任何错误输出,以找到破坏代码的原因。在网络浏览器中,一切正常 import React, { useState } from "react"; import { SafeAreaView, StyleSheet, TextInput, Button } from "

Mine react本机应用程序在web浏览器(react native+expo)中工作,但在android设备中,fetchCopiedText返回“null”和convertStr应用程序。我可以看到任何错误输出,以找到破坏代码的原因。在网络浏览器中,一切正常

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 (
  <SafeAreaView>
  <Button title="copy" onPress={copyToClipboard} />
  <Button title="paste" onPress={fetchCopiedText} />
  <TextInput
    style={styles.input}
    onChange={(e) => setText(e.target.value)}
    value={text}
    multiline
    selectable
  />
  <Button title="clear all" onPress={clearAll} />
  <Button title="U Cyr" onPress={Ucyr} />
</SafeAreaView>
 );
 };

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

export default Cyr;
import React,{useState}来自“React”;
从“react native”导入{SafeAreaView、样式表、文本输入、按钮};
从“expo剪贴板”导入剪贴板;
常数Cyr=()=>{
const[text,setText]=useState(“”);
const copyToClipboard=()=>{
剪贴板.setString(文本);
console.log(文本);
};
常量fetchCopiedText=async()=>{
const text=wait Clipboard.getStringAsync();
setText(文本);
};
常量clearAll=()=>{
setText(“”);
};
const convertStr=()=>{
塞特克斯(
文本
.替换(/x/g,“xx”)
.替换(/y/g,“yy”)
.替换(/t/g,“tt”)
.替换(/\.([^\s\d])/g,“.$1”)
.替换(/\,([^\s\d])/g,“,$1”)
);
};
返回(
setText(e.target.value)}
值={text}
多行
可选的
/>
);
};
const styles=StyleSheet.create({
输入:{
身高:300,
宽度:400,
差额:12,
边框宽度:1,
},
});
导出默认Cyr;