Skip to content

Commit

Permalink
add getServerSnapshot to react store
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Dec 15, 2023
1 parent 8d82d46 commit 2644716
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 141 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-worms-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect-rx/rx-react": patch
---

add getServerSnapshot to react store
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"eslint.validate": ["markdown", "javascript", "typescript"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.quickSuggestions": {
"other": true,
Expand All @@ -38,7 +38,7 @@
"editor.tabCompletion": "off",
"editor.suggest.localityBonus": true,
"editor.suggestSelection": "recentlyUsed",
"editor.wordBasedSuggestions": true,
"editor.wordBasedSuggestions": "matchingDocuments",
"editor.parameterHints.enabled": true,
"files.watcherExclude": {
"**/target": true
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@
},
"devDependencies": {
"@babel/cli": "^7.23.4",
"@babel/core": "^7.23.5",
"@babel/core": "^7.23.6",
"@babel/plugin-transform-export-namespace-from": "^7.23.4",
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@effect/build-utils": "^0.7.0",
"@effect/build-utils": "^0.7.1",
"@effect/docgen": "^0.3.8",
"@effect/eslint-plugin": "^0.1.2",
"@effect/language-service": "^0.1.0",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitest/coverage-v8": "^1.0.4",
"babel-plugin-annotate-pure-calls": "^0.4.0",
"eslint": "^8.55.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-codegen": "^0.21.0",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-sort-destructure-keys": "^1.5.0",
"fast-check": "^3.14.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/rx-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"license": "MIT",
"sideEffects": false,
"devDependencies": {
"@types/react": "^18.2.43",
"@types/react": "^18.2.45",
"effect": "2.0.0-next.60",
"react": "^18.2.0"
},
Expand Down
4 changes: 3 additions & 1 deletion packages/rx-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ function makeStore<A>(registry: Registry.Registry, rx: Rx.Rx<A>): RxStore<A> {

function useStore<A>(registry: Registry.Registry, rx: Rx.Rx<A>): A {
const store = makeStore(registry, rx)
return React.useSyncExternalStore(store.subscribe, store.snapshot)
return React.useSyncExternalStore(store.subscribe, store.snapshot, () => {
return undefined as A
})
}

/**
Expand Down
Loading

0 comments on commit 2644716

Please sign in to comment.