Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6214

TypeError: X is not a function, 'X' is undefined

$
0
0

I'm trying to implement the login functionality in a react native project but the following error occurs:

[TypeError: signIn is not a function. (In 'signIn({ email: data.email, password: data.password })', 'signIn' is undefined)]

function that is called when submitting the form:

  const handleSignIn = useCallback(    async (data: SignInFormData) => {      try {        console.log('chegou');        await signIn({          email: data.email,          password: data.password,        });      } catch (err) {        console.log(err);        Alert.alert('Erro na autenticação','Ocorreu um erro ao fazer login, cheque suas credenciais',        );      }    },    [signIn],  );

signIn function that is created in auth.tsx:

  const signIn = useCallback(async ({email, password}) => {    const response = await api.post('sessions', {      email,      password,    });    const {token, user} = response.data;    await AsyncStorage.multiSet([      ['@Proffy:token', token],      ['@Proffy:user', JSON.stringify(user)],    ]);    api.defaults.headers.authorization = `Bearer ${token}`;    setData({token, user});  }, []);

the repository where the project is: https://github.com/cp-yago/proffy-mobile


Viewing all articles
Browse latest Browse all 6214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>