I have two loggers but i am facing a problem. i want something similar to this. HOwever if i use only one logger without the if case then it works fine.
if(process.env.NODE_ENV === 'DEVELOPMENT')
{
export default logger_dev;
}
if(process.env.NODE_ENV === 'PRODUCTION')
{
export default logger_prod;
}
In React, you can create distinct components that encapsulate behavior you need. Then, you can render only some of them, depending on the state of your application. Conditional rendering in React works the same way conditions work in JavaScript.
There are two ways to do this. The first one is to use something like redux. where you have global store for the state which can be shared across different components. import React, {Component} from 'react'; import './App.
We can embed any JavaScript expression in JSX by wrapping it in curly braces. But only expressions not statements, means directly we can not put any statement (if-else/switch/for) inside JSX.
const logger = process.env.NODE_ENV === 'PRODUCTION' ? logger_prod : logger_dev;
export default logger;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With