Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
Reset state instead of an empty string

Newbie here.

I'll try my best to explain the issue.

Basically, I have this function that populates a form with existing data if the person filling out the form is the same as the user that logged in.

I'm trying now to reverse this function, so that if the user undoes this function, the form resets - i.e. as if it wasn't filled.

My issue is that I want to reset back to the initial state of name.

The way input field is formatted, having name : null or name : "" makes the form look like it's "filled". Just with no characters in the field itself.

How would I go about this?

  const handleSameUser = useCallback(() => {
    const newState = !sameUser
    setSameUser(newState);
    if (newState && user) {
      handleUserDetails({
        name: user?.name,
        profilePic: user?.avatar,
      });
    } else {
      handleUserDetails({ profilePic: null, name: ""});
    }
  }, [sameUser, setSameUser, user]);

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!