Reputation: 941
I have this if/else statement
import { isMobile } from 'react-device-detect'
const MoneyManagementOffers = ({ text, title }) => {
const renderContent = () => {
const checkDevice = isMobile ? <h1>Gela</h1> : <h1>Margo</h1>
return checkDevice
}
Somehow it will always return <h1>Gela</h1>
and I don't know why, Any suggestions, please?
Upvotes: 0
Views: 64
Reputation: 119
import { isMobile } from "react-device-detect";
const App = () => {
const checkDevice = isMobile ? <h1>Gela</h1> : <h1>Margo</h1>;
return <>{checkDevice}</>;
};
export default App;
This code works fine, maybe you need to switch to/from a mobile device view in your dev tools to see 'Gela' or 'Margo'.
Upvotes: 1