Skip to content

Instantly share code, notes, and snippets.

@notsidney
Last active December 8, 2021 01:06
Show Gist options
  • Save notsidney/d0caa489ee77da35d9af19ec085ac4d2 to your computer and use it in GitHub Desktop.
Save notsidney/d0caa489ee77da35d9af19ec085ac4d2 to your computer and use it in GitHub Desktop.
Jotai atomWithHash example
const modalOpenAtom = atomWithHash("modalOpen", false, {
replaceState: true,
});
import { atomWithHash } from "jotai/utils";
export const modalOpenAtom = atomWithHash("modalOpen", false);
cloudLogFilters = {
"type": "build",
"timeRange": { "type": "days", "value": 7 },
"buildLogExpanded": 1
}
import { useAtom } from "jotai";
import { modalOpenAtom } from "./atoms";
function ExampleModal() {
const [open, setOpen] = useAtom(modalOpenAtom);
return (
<Dialog
open={open}
onClose={() => setOpen(false)}
...
/>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment