1

I'm working on the user account creation feature of my solid-js application. The problem is that when I click on the button leading to the user account creation form, it does not react and in browser command line, I get the error: Type error: loading is not a function

Here is the content of my Signup.jsx file:

const { form, handleInput, handleSignup, handleRadioChange, loading } =
  useSignup();

      . . .
           <button
              type="submit"
              disabled={loading()}
              className="w-full  py-2 px-3 bg-blue-500 text-white rounded-lg text-lg"
            >
              <Show when={!loading()} fallback={"Signing up..."}>
                Sign Up
              </Show>
            </button>

my UseSignup.jsx file:

const [loading, setLoading] = createSignal(false);
     . . .
const handleSignup = async (ev) => {
    ev.preventDefault();
    setLoading(true);
    try {
      const { data } = await sendEmail( {
        ...form,
        platform,
        coords: geolocationStore.store.coords,
      });
      addSnackbar({ type: "success", message: data.message });
      navigate("/auth/verifyEmail");
      sessionStorage.setItem('code',data.data.code)
      const code = sessionStorage.getItem('code')
      return code;
    } catch (error) {
      addSnackbar({ type: "error", message: error.response.data.message });
    } finally {
      setLoading(false);
    }
  };

return {
    loading,
     ...
  };

I don't understand why I get this error yet according to me, I have defined the loading function correctly. I looked on several stackoverflow questions but nothing. Thanks and I look forward to your answers!

Samathingamajig
  • 11,839
  • 3
  • 12
  • 34
Goune Kenfack
  • 107
  • 1
  • 7

0 Answers0