#useState doesn't update as intended

6 messages · Page 1 of 1 (latest)

iron ocean
#

I'm trying to make a form that goes over different pages, so I have made a global state for just the form, but even tho my test form are the same I get different results, first page doesn't update second one is just wierd
all the code is here in github https://github.com/TOcvfan/formtest/
if I console.log e I get { fornavn: "whatever I typed" } on the first page and { fisse: "whatever I typed" } on the second page

GitHub

Contribute to TOcvfan/formtest development by creating an account on GitHub.

junior onyxBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

iron ocean
#

Okay apparently nobody knows the solution to my problem or don't want to tell me..
luckily I found out myself

junior onyxBOT
#
✅ Success!

This question has been marked as answered! If you have any other questions, feel free to create another post

Jump to answer
ocean thunder
iron ocean
#

instead of this
const onSubmitSignIn = async (e) => { console.log(e) setData({ ...data, e }) router.push("/opret/bruger/info2"); }
I used this
const onSubmitSignIn = async (e) => { console.log(e) setData(data => ({ ...data, ...e })) router.push("/opret/bruger/info2"); }