As soon as I add an object to "setTitle" I get an error. Setting the object in "useState()" works.
import React, { useState } from "react";
export default function App() {
const [title, setTitle] = useState({});
setTitle({
"somthing": "dfgsf"
});
return <p>df</p>;
}
Too many re-renders. React limits the number of renders to prevent an infinite loop.
Live: https://codesandbox.io/s/custom-hook-playground-bzt6s?file=/src/App.js