Skip to content

Commit

Permalink
Merge pull request #23 from react18-tools/fix-ssr
Browse files Browse the repository at this point in the history
Fix SSR build
  • Loading branch information
mayank1513 committed May 1, 2024
2 parents 4bcdcae + eb3875e commit 7c0353d
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 10 deletions.
8 changes: 8 additions & 0 deletions examples/nextjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# nextjs-example

## 0.0.13

### Patch Changes

- Updated dependencies
- [email protected]
- [email protected]

## 0.0.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nextjs-example",
"version": "0.0.12",
"version": "0.0.13",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
8 changes: 8 additions & 0 deletions examples/remix/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# remix-example

## 0.0.13

### Patch Changes

- Updated dependencies
- [email protected]
- [email protected]

## 0.0.12

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions examples/remix/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "remix-example",
"version": "0.0.12",
"version": "0.0.13",
"private": true,
"sideEffects": false,
"type": "module",
Expand All @@ -16,7 +16,7 @@
"@remix-run/node": "^2.9.1",
"@remix-run/react": "^2.9.1",
"@remix-run/serve": "^2.9.1",
"isbot": "5.1.5",
"isbot": "5.1.6",
"nthul-lite": "^0.2.0",
"r18gs": "workspace:*",
"react": "^18.3.1",
Expand Down
8 changes: 8 additions & 0 deletions examples/vite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# vite-example

## 0.0.13

### Patch Changes

- Updated dependencies
- [email protected]
- [email protected]

## 0.0.12

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions examples/vite/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vite-example",
"private": true,
"version": "0.0.12",
"version": "0.0.13",
"type": "module",
"scripts": {
"dev": "vite --port 3001",
Expand All @@ -20,8 +20,8 @@
"devDependencies": {
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"@vitejs/plugin-react-swc": "^3.6.0",
"eslint": "^9.1.1",
"eslint-plugin-react-hooks": "^4.6.2",
Expand Down
6 changes: 6 additions & 0 deletions lib/r18gs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# r18gs

## 1.0.1

### Patch Changes

- Fix SSR build

## 1.0.0

### Major Changes
Expand Down
6 changes: 3 additions & 3 deletions lib/r18gs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "r18gs",
"author": "Mayank Kumar Chaudhari <https://mayank-chaudhari.vercel.app>",
"private": false,
"version": "1.0.0",
"version": "1.0.1",
"description": "A simple yet elegant, light weight, react18 global store to replace Zustand for better tree shaking.",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -34,7 +34,7 @@
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "^1.5.2",
"@vitest/coverage-v8": "^1.5.3",
"eslint-config-custom": "workspace:*",
"jsdom": "^24.0.0",
"octokit": "^3.2.0",
Expand All @@ -48,7 +48,7 @@
"typedoc-plugin-zod": "^1.1.2",
"typescript": "^5.4.5",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.5.2"
"vitest": "^1.5.3"
},
"peerDependencies": {
"@types/react": "16.8 - 18",
Expand Down
6 changes: 5 additions & 1 deletion lib/r18gs/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ export function createSetter<T>(key: string): SetStateAction<unknown> {
/** Extract coomon create hook logic to utils */
export function createHook<T>(key: string): [T, SetStateAction<T>] {
const rgs = globalRGS[key] as RGS;
const val = useSyncExternalStore<T>(rgs[SUBSCRIBER] as Subscriber, () => rgs[VALUE] as T);
const val = useSyncExternalStore<T>(
rgs[SUBSCRIBER] as Subscriber,
() => rgs[VALUE] as T,
() => rgs[VALUE] as T,
);
return [val, rgs[SETTER] as SetStateAction<T>];
}

Expand Down

0 comments on commit 7c0353d

Please sign in to comment.