Checking state variable in console.log