I don't understand, I'm trying to improve my app.js code by adding a function 'languageSetUp()' to useEffect and I find myself facing the error:
destroy is not a function. (In 'destroy()', 'destroy' is an instance
of Object)
Do you know what it is due to? And what does that mean? I do not understand where the problem is, if you can help me and especially explain to me, I thank you in advance. Thanks for any time or help offered.
After search I think it's due to 'this.props' I don't know how to replace it in a functionnal component at first I wanted to do :
if (isConnected === true && this.props && this.props.navigation) {
this.props.navigation.navigate("BottomTabNavigator");
} }
export default function App() {
Text.defaultProps = Text.defaultProps || {};
Text.defaultProps.allowFontScaling = false;
const [user, setUser] = useState({ loggedIn: false });
const state = { user, setUser };
const [loading, setLoading] = useState(true);
async function languageSetUp() {
let lang = await retrieveAppLang();
let isConnected = await userSessionActive();
if (lang.length == 2) {
i18n.changeLanguage(lang);
}
if (isConnected === true) {
this.props.navigation.navigate("BottomTabNavigator");
}
}
React.useEffect(() => {
setTimeout(() => setLoading(false), 2000);
languageSetUp();
if (loading) {
return <Splash />;
}
});
return (
<AppContext.Provider value={state}>
<NavigationContainer>
{!user.loggedIn ? (
<MainStackNavigator />
) : (
<BottomTabNavigator />
)}
</NavigationContainer>
</AppContext.Provider>
);
}
question from:
https://stackoverflow.com/questions/66048830/understand-error-destroy-is-not-a-function 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…