在我的应用中,我想从
开始的EditText视图中编辑一些文本。max =
我想通过按一个按钮在“编辑模式”和“只读模式”之间切换来做到这一点。
我正在使用import React, { useState, useEffect, useRef, createRef } from "react";
import ReactDOM from "react-dom";
function Counter() {
const [countSec, setCountSec] = useState(0);
const [countMin, setCountMin] = useState(0);
useInterval(() => {
setCountSec(countSec + 1); // this working
}, 1000, 0);
useInterval(() => {
setCountMin(countMin + 1); // it's not working
}, 1100, 1);
return <div>
<h1>{countSec} Secounds</h1>
<h1>{countMin} Half-Minutes</h1>
</div>;
}
function useInterval(callback, delay,index){
const savedCallback = useRef([...Array(2)].map(()=> createRef()));
// Remember the latest function.
useEffect(() => {
savedCallback.current[index].current = callback;
}, [callback]);
// Set up the interval.
useEffect(() => {
let id = setInterval(()=>savedCallback.current[index].current(), delay);
return () => clearInterval(id);
});
};
和setFocusableInTouchMode(false).
。一切正常,但我无法解决的问题是软键盘仅在第一次自动出现。在重复编辑(这意味着反复按下和关闭按钮)时,软键盘只能手动重新出现。
这是我的代码
showSoftInput