'First-time signed up user is created only after reloading the app in React Native w/ AWS Amplify-GraphQL

i'm using AWS Amplify Cognito + Graphql in order to sign in and sign up users to my app. In order to do so, i wrapped it in a HOC Authenticator component, switching from withAuthenticator. Since i made this switch to Authenticator, now newly signed up users who sign in for the very first time need to reload to app to fetch their account data, because, during this very first signin, the app does not fetch their sub (ID). I believe that the reason for this is (i noticed this particular behavior) that their user table are now getting created in DynamoDB only after reloading the app, and not during the signup process as it was before. Any idea what might be the cause for this issue? App.js is as following:

const App= () => {

     useEffect( () => {
    const fetchUser = async () => {
       const userInfo = await Auth.currentAuthenticatedUser({ bypassCache: true});

            const newUser = {
              id: userInfo.attributes.sub, 
              title: "User",
            }

      try { 
        await API.graphql(graphqlOperation( createUser, { input: newUser } ) )
        console.log("User Created")
      } catch (err) { console.log(err)}

     };

    fetchUser()
  }, [])

SignUp.js

async function onSubmitSignup() {
    const {email, preferred_username, password} = values;
    try {
      const user = await Auth.signUp({
        username: email,
        password,
        attributes: {
          preferred_username,
        },
      });

      const newUser = {
        id: 1235352346456, 
        title: "User",
      }
      try { 
        await API.graphql(graphqlOperation( createUser, { input: newUser } ) )
        console.log("User Created")
      } catch (err) { console.log("enr3",err)};

      props.onStateChange('confirmSignUp', user);
    } catch (error) {
      console.log('error', error);
      setError(error.message);
    }
  }


Solution 1:[1]

Create User right after Sign Up process. In your code, you're trying to create user every time you access the website.

const res = await Auth.signUp({
  username: email,
  password,
  attributes: {
    "custom:username": username,
  },
});

const user = {
  id: username,
  sub: res.userSub,
  email,
};

await API.graphql(graphqlOperation(createUser, { input: user }));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LuckyTuvshee