<View onTouchStart={() => doSomething()} />
import React, { useState, useEffect, useRef } from "react";
import "./styles.css";
export default function App() {
let [text, setText] = useState("q");
let textRef = useRef(text);
useEffect(() => {
console.log(text + " first");
return () => {
console.log(textRef.current + " second");
};
}, [text]);
return (
<div className="App">
<h1>{text}</h1>
<button
onClick={() => {
setText(text + "q");
textRef.current = textRef.current + "q";
}}
>
click
</button>
</div>
);
}
<script type="module" src="./index.js"></script>
сработало , спасибо