Home > other >  React native app blank white screen on hitting sign in
React native app blank white screen on hitting sign in

Time:12-16

I am trying to build login functionality on react-native app , i am showing the api response on same screen either error or success in Text tags, this feature works perfectly on android emulator.when i install the release apk in my phone when i hit login the screen goes whitescreen.

const [loginUser, {isLoading, error, data, isSuccess, isError}] = useLoginUserMutation();

const OnSignInPressed = async () => {
    console.log("onsigninpressed")
    const formData = {email, password}
    res = await loginUser(formData);
    console.log("res", res.data.message)
    console.log("resss", res)
    if (res.data.message === 'User logged in successfully') {
        dispatch(login())
    }
}

return (
  <View style={styles.root}>
      <Text>Api Responses</Text>
      {isSuccess && <Text>success message: {data.message}</Text>}
      {error && <Text>error message: {error.data.message}</Text>}
      {error && <Text>error status: {error.status}</Text>}
      <Image source={Logo} style={styles.logo} resizeMode='contain'/>
      <Custominput placeholder="Email" value={email} setValue={setEmail}
                   autoCapitalize='none'/>
      <Custominput placeholder="Password" value={password} setValue={setPassword}
                   secureTextEntry={true}/>
      {/* <Custombutton text='Sign In' onPress={OnSignInPressed}/> */}
      <Button
        onPress={() => OnSignInPressed()}
        title="Sign in"
        color="#841584"
      />
      <Custombutton text='Forgot Password' type="TERTIARY" onPress=.
        {onForgotPressed}/>
      <Custombutton text="Don't have an account ? Create one" type="TERTIARY"
                    onPress={onSignupPressed}/>
  </View>

)

CodePudding user response:

A white screen means you are getting an error on the JS side. Looks like when you work on your emulator you catch this error and don't stop the app, check your console.

To add a global error handler you can use this solution https://github.com/a7ul/react-native-exception-handler

CodePudding user response:

instead of res=await loginUser(formData); it should be more like const res = await loginUser(formData);

javascript variables must start with either const,let,var

  • Related