const [obj,setObj] = useState([{...},{...},{...}])
...
setObj(
[...obj].map( targetObject =>{
targetObject.someValue = 0;
return targetObject ;
}
))
useEffect(() => {
// Anything in here is fired on component mount.
console.log("mount");
return () => {
// Anything in here is fired on component unmount.
console.log("unmount");
// setValues({ input: "", textarea: "" }
};
}, []);
const clickToBtn = (e) => {
setString(e.target.textContent);
testing();
};
const [count, setCount] = useState(0);
const [string, setString] = useState("");
const srollContainer = useRef(null);
const flag = useRef(false);
const scroll = (n) => srollContainer.current.scrollTo({ top: n * 100, behavior: "smooth" });
const clickToBtn = (e) => {
setString(e.target.textContent);
testing();
};
const testing = () => {
if (string === "go to 3 slide") {
setCount(3);
return false;
}
setCount(count + 1);
};
useEffect(() => {
if (!flag) return false;
scroll(count);
});