I'm reasonably new to RN and having what will prob be a basic issue with setting state - Currently I have the following - various tasks run in the constructor but the setState tasks dont work - Ive tried the same function in componentdidmount and get the same issue - can anyone please explain where i'm going wrong?
import React from 'react';
import { connect } from "react-redux";
import {View, Image, StyleSheet, Text, StatusBar, TouchableOpacity, ScrollView} from 'react-native';
import CopyrightSpiel from './util/CopyrightSpiel';
import ButtonHomeNav from './util/ButtonHomeNav';
import BlinkMe from './util/BlinkMe';
import PropTypes from 'prop-types';
import moment from 'moment';
import { withNavigation } from 'react-navigation';
class HomeView extends React.Component {
constructor(props) {
super(props);
this.state = {
loggedIn:false,
expDateClose :false,
expDays : 0,
};
console.warn('daysRem');
let curDate= new Date();
let expDate= new Date(this.props.user.badgeExpiry);
if (!moment.isMoment(curDate)) {curDate = moment(curDate);}
if (!moment.isMoment(expDate)) {expDate = moment(expDate);}
const daysRem = expDate.diff(curDate, 'days');
console.warn(daysRem);
if(daysRem >= 600){
console.warn(daysRem);
this.setState({expDays: 15});
console.warn(this.state.expDays);
console.warn(this.state.expDateClose);
}
}
render() {