I just started with react and next. I was wondering why the value is reloading on the webpage when I update a useState like this [test, setTest] = useState("test"), but not in the case below. Can anyone explain why and how to fix it?
const [testing, setTest] = useState({
name:"test"
})
function test(){
setTest(old =>{
old.name = "new name"
return old;
})
}
return (
<ThemeProvider theme={theme>
<button onClick={test} />
<GlobalStyles/>
<h1>{testing.name}</h1>
</ThemeProvider>
)