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