-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
push/pull activeServerStore state to/from url
- Loading branch information
Showing
8 changed files
with
73 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
'use client'; | ||
|
||
import { RecoilRoot } from 'recoil'; | ||
import dynamic from 'next/dynamic'; | ||
const RecoilURLSyncJSON = dynamic( | ||
() => import('recoil-sync').then((m) => m.RecoilURLSyncJSON), | ||
{ ssr: false } | ||
// This is magic. I get this error when I try to use RecoilURLSyncJSON directly. The functionality still works tho. | ||
// Error: | ||
// ⨯ node_modules/transit-js/transit.js (24:22) @ self | ||
// ⨯ ReferenceError: self is not defined | ||
// at __webpack_require__ (/home/lov432/vscode/cs2-dashboard/.next/server/webpack-runtime.js:33:42) | ||
// at __webpack_require__ (/home/lov432/vscode/cs2-dashboard/.next/server/webpack-runtime.js:33:42) | ||
// at eval (./app/components/RecoilRootWrapper.tsx:9:69) | ||
// at (ssr)/./app/components/RecoilRootWrapper.tsx (/home/lov432/vscode/cs2-dashboard/.next/server/app/page.js:453:1) | ||
// at __webpack_require__ (/home/lov432/vscode/cs2-dashboard/.next/server/webpack-runtime.js:33:42) | ||
// null | ||
// error | ||
); | ||
|
||
export default function RecoilRootWrapper({ | ||
children | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return <RecoilRoot>{children}</RecoilRoot>; | ||
return ( | ||
<RecoilRoot> | ||
<RecoilURLSyncJSON location={{ part: 'queryParams' }}> | ||
{children} | ||
</RecoilURLSyncJSON> | ||
</RecoilRoot> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { atom } from 'recoil'; | ||
import { syncEffect } from 'recoil-sync'; | ||
import { number } from '@recoiljs/refine'; | ||
|
||
type activeServerIndexStore = number; | ||
|
||
export const activeServerStore = atom({ | ||
export const activeServerStore = atom<number>({ | ||
key: 'activeServerStore', | ||
default: 0 as activeServerIndexStore | ||
effects: [syncEffect({ refine: number() })], | ||
default: 0 | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters