Use Jotai instead of React Context #65
|
@ -6,7 +6,7 @@ import { LightBox } from "components/LightBox";
|
|||
import { filterDefined } from "helpers/others";
|
||||
import { atomPairing, useAtomSetter } from "helpers/atoms";
|
||||
|
||||
export const lightBoxAtom = atomPairing(
|
||||
const lightBoxAtom = atomPairing(
|
||||
atom<{
|
||||
showLightBox: (
|
||||
images: (UploadImageFragment | string | null | undefined)[],
|
||||
|
@ -15,7 +15,7 @@ export const lightBoxAtom = atomPairing(
|
|||
}>({ showLightBox: () => null })
|
||||
);
|
||||
|
||||
export const lightBox = lightBoxAtom[0]
|
||||
export const lightBox = lightBoxAtom[0];
|
||||
|
||||
export const LightBoxProvider = (): JSX.Element => {
|
||||
const [isLightBoxVisible, setLightBoxVisibility] = useState(false);
|
||||
|
|
|
@ -6,7 +6,7 @@ import { atomPairing } from "helpers/atoms";
|
|||
import { settings } from "contexts/settings";
|
||||
import { lightBox } from "contexts/LightBoxProvider";
|
||||
|
||||
/*
|
||||
/*
|
||||
* I'm getting a weird error if I put those atoms in appLayout.ts
|
||||
* So I'm putting the atoms here. Sucks, I know.
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { atom } from "jotai";
|
||||
import { useRouter } from "next/router";
|
||||
import React, { useEffect } from "react";
|
||||
import { useEffect } from "react";
|
||||
import { useFetch } from "usehooks-ts";
|
||||
import { atomPairing, useAtomSetter } from "helpers/atoms";
|
||||
import {
|
||||
|
|
Loading…
Reference in New Issue