import React,{useRef,useState} from 'react'; import {View} from 'react-native'; import {Button,Card,Field,Heading,Note,s} from '../ui'; import {developmentServer} from '../core/server-address'; export function ServerConnection({address,onSave}:{address:string;onSave:(value:string)=>Promise}) { const [editing,setEditing]=useState(false),[value,setValue]=useState(address),[busy,setBusy]=useState(false),[error,setError]=useState(''); const lock=useRef(false); async function save(){ if(lock.current)return; lock.current=true; setBusy(true);setError(''); try{await onSave(developmentServer(value));setEditing(false);}catch(e){setError((e as Error).message);}finally{lock.current=false;setBusy(false);} } return 开发服务{address} {!editing?