I have defined a global variable in drawer component. I use this var in the same component and I change it, my approach works fine
import ....
...
const USERID_STORED = "userid_stored";
var userArray = [];
var lengthNow = 0;
...
class DrawerComponent extends React.Component {
_goToMessages = (route) => (
() => {
const navigateAction = NavigationActions.navigate({
routeName: route
});
this.props.navigation.dispatch(navigateAction);
this.props.navigation.closeDrawer();
lengthNow = userArray.length; // change it here
}
);
...
render (
...
)
}
but whene I reload the App, lengthNow takes back his initial value 0
Can I let lengthNow keep its value ? how can I do it ?
if you have another aproach propose it to me please