Hiding an Element in React

My issue

I’m trying to hide an element in React that is specifically for MacOS so I don’t want it shown on Windows.

The element has a class macButtons where I have styled it inline to check to see if the process is ‘darwin’

However is doens’t seem to hide the DIV on windows

My code so far

Any help would be much appreciated

You want ‘block’ for Mac and ‘inline’ for anything not Mac? Why are you using ‘inline’? Why not ‘none’?

I think you’re looking for something like this:

if (window.navigator.userAgent.indexOf("Mac") != -1) OSName="Mac/iOS";

See: https://stackoverflow.com/questions/9514179/how-to-find-the-operating-system-version-using-javascript

1 Like

Hey @Vidsify, welcome to forum! I suppose you code will run in browser, and browsers do not have process property. Therefore, as @pschorey pointed out:

function isMac() {
  return navigator && navigator.userAgent && /Macintosh/.test(navigator.userAgent);
1 Like