'React component does not re-render even if a state has changed

I'm trying to build a manual refresh for my app, so I came across creating a state inside the App component and then via props exporting the getter and setter, so that the setter can be called with the opposite value of getter. This works fine. The setter changes the state and and this even show the console.log in the App component but the re-render just isn't executed.

import { NavigationContainer } from '@react-navigation/native'
import AppNavigation from './navigation/AppNavigation.js'
import LoginNavigation from './navigation/LoginNavigation.js'
import { ThemeProvider } from 'react-native-magnus'
import { useState, useEffect, createContext} from 'react'
import { React } from 'react'
import getLoginSession from './utils/getLoginSession.js'
import { ActivityIndicator } from 'react-native'
import getIntroductionCompleted from './utils/getIntroductionCompleted.js'
import Introduction from './pages/Introduction.js'
import { LogBox } from 'react-native';
LogBox.ignoreLogs(['Warning: ...']); // Ignore log notification by message
LogBox.ignoreAllLogs();//Ignore all log notifications

const App = () => {
    const [reloadApp, setReloadApp] = useState(false);
    const [introductionCompleted, setIntroductionCompleted] = useState(false)
    const [loggedIn, setLoggedIn] = useState(false);
    const [loading, setLoading] = useState(true);
  
    useEffect(() => {
        (async () => {
            try {
                const Introduction = await getIntroductionCompleted();
                if (Introduction) {
                    setIntroductionCompleted(true);
                }
            } catch (error) {
                console.log(error);
            }
            setLoading(false);
        })();
    }, [])

    useEffect(() => {
      (async () => {
        try {
          const data = await getLoginSession();
          if (data != null) {
            setLoggedIn(true);
          }
        } catch (error) {
          setLoggedIn(false);
        }
        setLoading(false);
      })();
    }, []);
    console.log(reloadApp, introductionCompleted)
  
    return (
      <>
        {}
        {!loading || !(reloadApp | !reloadApp) ? (
            introductionCompleted ? (
                loggedIn ? (
                    <ThemeProvider>
                    <NavigationContainer>
                        <AppNavigation reloadFunc={setReloadApp} reloadValue={reloadApp}/>
                    </NavigationContainer>
                    </ThemeProvider>
                ) : (
                    <ThemeProvider>
                        <NavigationContainer>
                            <LoginNavigation reloadFunc={setReloadApp} reloadValue={reloadApp}/>
                        </NavigationContainer>
                    </ThemeProvider>
                )
                ) : (
                    <Introduction reloadFunc={setReloadApp} reloadValue={reloadApp} />
                    )
                    ) : (
                        <ActivityIndicator size="large" color="#0000ff" />
                        )
                    }
      </>
    );
  };

export { App }

This is the App Component and in it the reloadApp and setReloadApp are props of the Navigation / Introduction Components. When the introduction is completed, the AsyncStorage will be updated, so that the introduction wont be executed again. The introductionCompleted value is the check if the value is set in the AsyncStorage. Because of anything the useEffect isnt executed and the component doesnt re-render. Please help me....



Solution 1:[1]

If A and B are Entities, you can use @PrePersist annotation. Simply @PrePersit means Before Insert, so you can check the entries in B before inserting in A.

Class A{
int id;
String name;

@PrePersist
public void beforeInsert(){
//if B has certain entry
//then save in Join
}
}

Solution 2:[2]

You can just check if B has certain entries while posting A. You can check that using the JPA repository methods of B.

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 Ibrahim_Fneich
Solution 2 Ashwini Karnale