title: How to useEffect cleanup function in react native?
body: <p>Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in %s.%s, a useEffect cleanup function,</p>
  
  <pre><code>const Drawer = createDrawerNavigator();
  
  const App = () =&gt; {
    const [isLoading, setIsLoading] = React.useState(true);
    const [userToken, setUserToken] = React.useState(null);
  
    const authContext = React.useMemo(() =&gt; ({
      SignIn: () =&gt; {
        setUserToken('qwertyuiop');
        setIsLoading(false);
      },
      SignOut: () =&gt; {
        setUserToken(null);
        setIsLoading(false);
      },
      SignUp: () =&gt; {
        setUserToken('qwe');
        setIsLoading(false);
      },
    }));
  
    useEffect(() =&gt; {
      setTimeout(() =&gt; {
        setIsLoading(false);
      }, 1000);
    }, []);
  
    if (isLoading) {
      return (
        &lt;View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}&gt;
          &lt;ActivityIndicator size="large" /&gt;
        &lt;/View&gt;
      );
    }
  
    console.log("userToken", userToken)
    console.log("authContext", authContext)
    return (
      &lt;AuthContext.Provider value={authContext}&gt;
        &lt;NavigationContainer&gt;
          {userToken !== null ? (
            &lt;Drawer.Navigator drawerContent={props =&gt; &lt;DrawerContent {...props} /&gt;}&gt;
              &lt;Drawer.Screen name="HomeDrawer" component={MainTabScreen} /&gt;
              &lt;Drawer.Screen name="Support" component={SupportScreen} /&gt;
              &lt;Drawer.Screen name="Setting" component={SettingScreen} /&gt;
              &lt;Drawer.Screen name="Bookmark" component={BookmarkScreen} /&gt;
            &lt;/Drawer.Navigator&gt;
          )
            :
            &lt;RootStackScreen /&gt;
          }
        &lt;/NavigationContainer&gt;
      &lt;/AuthContext.Provider&gt;
    );
  }
  </code></pre>