Fix Docusaurus server side render error (#301)
Co-authored-by: Hien To <tominhhien97@gmail.com>
This commit is contained in:
parent
27ab18bddc
commit
1a33c493e4
@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { Fragment } from "react";
|
import { Fragment } from "react";
|
||||||
import { Menu, Transition } from "@headlessui/react";
|
import { Menu, Transition } from "@headlessui/react";
|
||||||
import { ChevronDownIcon } from "@heroicons/react/20/solid";
|
import { ChevronDownIcon } from "@heroicons/react/20/solid";
|
||||||
@ -31,19 +31,22 @@ function classNames(...classes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Dropdown() {
|
export default function Dropdown() {
|
||||||
const uAgent = window.navigator.userAgent;
|
const [defaultSystem, setDefaultSystem] = useState(systems[0]);
|
||||||
let defaultSystem;
|
|
||||||
|
|
||||||
if (uAgent.indexOf("Win") !== -1) {
|
useEffect(() => {
|
||||||
defaultSystem = systems[2];
|
const uAgent = window.navigator.userAgent;
|
||||||
} else if (uAgent.indexOf("Mac") !== -1) {
|
|
||||||
// Note: There's no way to detect ARM architecture from browser. Hardcoding to M1/M2 for now.
|
if (uAgent.indexOf("Win") !== -1) {
|
||||||
defaultSystem = systems[0];
|
setDefaultSystem(systems[2]);
|
||||||
} else if (uAgent.indexOf("Linux") !== -1) {
|
} else if (uAgent.indexOf("Mac") !== -1) {
|
||||||
defaultSystem = systems[3];
|
// Note: There's no way to detect ARM architecture from browser. Hardcoding to M1/M2 for now.
|
||||||
} else {
|
setDefaultSystem(systems[0]);
|
||||||
defaultSystem = systems[0];
|
} else if (uAgent.indexOf("Linux") !== -1) {
|
||||||
}
|
setDefaultSystem(systems[3]);
|
||||||
|
} else {
|
||||||
|
setDefaultSystem(systems[0]);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="inline-flex align-items-stretch">
|
<div className="inline-flex align-items-stretch">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user