Skip to content

setUser not setting the value to the localStorage #38

@aynuayex

Description

@aynuayex

Describe the bug
i have just copied from the docs directly and used it like below the the user key value is not set on the localStorage, and i do not even think this library works?
here is the version "use-local-storage": "^3.0.0",
here is the code

export default function Login() {
const [user, setUser] = useLocalStorage("user",{});

async function onSubmit(values: z.infer<typeof formSchema>) {
    try {
      const { userId, password } = values;
      const response = await axios.get(
        `${
          import.meta.env.VITE_BASE_API
        }/Login/SignIn?UidCod=${userId}&UidPwd=${password}`
      );
      console.log(response.data)
      if (response.statusText === "OK") {
        setUser(response.data);
        navigate("/out_patient");
        return;
      }
    } catch (err) {
      console.log(err);
    }
  }
return (<>It does not work I should just stick to the localStorage API or built my own or use another one!</>);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions