193
rated 0 times
[
195]
[
2]
/ answers: 1 / hits: 5999
/ 4 Years ago, sat, october 24, 2020, 12:00:00
I'm writing a small function in Next JS with react. When I use navigator, I get the following error.
ReferenceError: navigator is not defined
Here's my code:
import React from "react";
export default function App() {
const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
return (
{isMac ? "I'm mac" : "I'm windows"}
);
}
How do I get browser platform and then render a section based on that?
More From » reactjs