You can not declare hooks conditionally. You can declare on the top level and you can put your business logic inside the hook, e.g below.
useEffect(() => {
if (process.env.NODE_ENV !== 'production'){
console.log("authToken changed", authToken);
if (tokenExpiresOn) {
console.log(
`token expires in ${(tokenExpiresOn - Date.now()).toLocaleString()}ms`
);
}
}
}, [authToken]);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…