@primer/react
Version:
An implementation of GitHub's Primer Design System using React
35 lines (31 loc) • 911 B
JavaScript
var reactCompilerRuntime = require('react-compiler-runtime');
var utils = require('@primer/behaviors/utils');
var React = require('react');
var environment = require('../utils/environment.js');
/**
* SSR-safe hook for determining if the current platform is MacOS. When rendering
* server-side, will default to non-MacOS and then re-render in an effect if the
* client turns out to be a MacOS device.
*/
function useIsMacOS() {
const $ = reactCompilerRuntime.c(2);
const [isMacOS, setIsMacOS] = React.useState(_temp);
let t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = () => setIsMacOS(utils.isMacOS());
t1 = [];
$[0] = t0;
$[1] = t1;
} else {
t0 = $[0];
t1 = $[1];
}
React.useEffect(t0, t1);
return isMacOS;
}
function _temp() {
return environment.canUseDOM ? utils.isMacOS() : false;
}
exports.useIsMacOS = useIsMacOS;
;