7 months ago
While developing my Android APP with React Native, I came across many situation where we have load data only if User is Logged In.
We have to call useEffect under if else.
Solution:
React Native JSX doesn't allow useEffect to put under if else condition. But we can put if else condition inside useEffect.
Sample Code:
useEffect(() => {
if(user != null){
dispatch.Property.getProposals({
email: user.email,
userId: user.id,
});
dispatch.Property.getTenants({
userId: user.id,
});
}
}, []);
Business Analyst at HCL Singapore
7 months ago