Skip to content

feat: new hooks and actions APIs#306

Open
KevinVandy wants to merge 14 commits intomainfrom
hooks
Open

feat: new hooks and actions APIs#306
KevinVandy wants to merge 14 commits intomainfrom
hooks

Conversation

@KevinVandy
Copy link
Copy Markdown
Member

@KevinVandy KevinVandy commented Apr 11, 2026

🎯 Changes

Introduces a complete set of framework hooks/injection functions across all adapter packages, adds store actions to the core Store API, and moves shallow to @tanstack/store core.

Core (@tanstack/store)

  • Store actionsStore now accepts an optional actions factory as a second argument. The factory receives { setState, get } and returns a typed actions bag accessible via store.actions.
    const store = createStore(
      { count: 0 }, 
      ({ setState, get }) => ({
        inc: () => setState((prev) => ({ count: prev.count + 1 })),
        log: () => console.log(get()),
      })
    )
    store.actions.inc()
  • New types: StoreAction, StoreActionMap, StoreActionsFactory
  • Store.subscribe, Store.setState, and Store.get are now bound in the constructor, so they can be safely destructured
  • shallow moved from individual adapter packages to @tanstack/store core (re-exported by all adapters automatically)

@tanstack/react-store

Hook Description
useSelector(source, selector, options?) Primary read hook — selects a slice of state
useValue(source, options?) Reads the whole value of an atom or store
useAtom(atom, options?) Returns [value, atom.set] tuple
useCreateAtom(initialValue, options?) Creates a stable atom instance per component
useCreateStore(initialValue, actions?) Creates a stable store instance per component
createStoreContext<T>() Creates typed { StoreProvider, useStoreContext } for React context
_useStore(store, selector, options?) Experimental — returns [selected, actions | setState] tuple
useStore Deprecated — alias for useSelector

@tanstack/vue-store

Hook Description
useSelector(source, selector, options?) Selects a slice of state, returns Readonly<Ref<T>>
useValue(source, options?) Returns the whole value as Readonly<Ref<T>>
useAtom(atom, options?) Returns [Readonly<Ref<T>>, atom.set] tuple
_useStore(store, selector, options?) Experimental — returns [Ref, actions | setState] tuple
useStore Deprecated — alias for useSelector

@tanstack/solid-store

Hook Description
useSelector(source, selector, options?) Selects a slice of state, returns Accessor<T>
useValue(source, options?) Returns the whole value as Accessor<T>
useAtom(atom, options?) Returns [Accessor<T>, atom.set] tuple
_useStore(store, selector, options?) Experimental — returns [Accessor, actions | setState] tuple
useStore Deprecated — alias for useSelector

@tanstack/preact-store

Hook Description
useSelector(source, selector, options?) Primary read hook — selects a slice of state
useValue(source, options?) Reads the whole value of an atom or store
useAtom(atom, options?) Returns [value, atom.set] tuple
useCreateAtom(initialValue, options?) Creates a stable atom instance per component
useCreateStore(initialValue, actions?) Creates a stable store instance per component
createStoreContext<T>() Creates typed { StoreProvider, useStoreContext } for Preact context
_useStore(store, selector, options?) Experimental — returns [selected, actions | setState] tuple
useStore Deprecated — alias for useSelector

@tanstack/angular-store

Hook Description
injectSelector(source, selector, options?) Selects a slice of state, returns Signal<T>
injectValue(source, options?) Returns the whole value as Signal<T>
injectAtom(atom, options?) Returns WritableAtomSignal<T> — callable signal with .set()
createStoreContext<T>() Creates typed { provideStoreContext, injectStoreContext } for Angular DI
_injectStore(store, selector, options?) Experimental — returns [Signal, actions | setState] tuple
injectStore Deprecated — alias for injectSelector

@tanstack/svelte-store

Hook Description
useSelector(source, selector, options?) Selects a slice of state, returns { readonly current: T }
useValue(source, options?) Returns the whole value as { readonly current: T }
useAtom(atom, options?) Returns [{ readonly current: T }, atom.set] tuple
_useStore(store, selector, options?) Experimental — returns [{ readonly current }, actions | setState] tuple
useStore Deprecated — alias for useSelector

Deprecations (Will be breaking before 1.0)

  • useStore (all adapters) is now deprecated — use useSelector instead

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 2026

Important

Review skipped

Too many files!

This PR contains 273 files, which is 123 over the limit of 150.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 95dff4dc-9d11-4e3e-95e4-473178440bba

📥 Commits

Reviewing files that changed from the base of the PR and between 47f9806 and 44daa4c.

📒 Files selected for processing (273)
  • .gitignore
  • docs/config.json
  • docs/framework/angular/quick-start.md
  • docs/framework/angular/reference/functions/createStoreContext.md
  • docs/framework/angular/reference/functions/injectAtom.md
  • docs/framework/angular/reference/functions/injectSelector.md
  • docs/framework/angular/reference/functions/injectStore-1.md
  • docs/framework/angular/reference/functions/injectStore.md
  • docs/framework/angular/reference/functions/injectValue.md
  • docs/framework/angular/reference/index.md
  • docs/framework/angular/reference/interfaces/InjectSelectorOptions.md
  • docs/framework/angular/reference/interfaces/WritableAtomSignal.md
  • docs/framework/angular/reference/type-aliases/SelectionSource.md
  • docs/framework/preact/quick-start.md
  • docs/framework/preact/reference/functions/createStoreContext.md
  • docs/framework/preact/reference/functions/shallow.md
  • docs/framework/preact/reference/functions/useAtom.md
  • docs/framework/preact/reference/functions/useCreateAtom.md
  • docs/framework/preact/reference/functions/useCreateStore.md
  • docs/framework/preact/reference/functions/useSelector.md
  • docs/framework/preact/reference/functions/useStore-1.md
  • docs/framework/preact/reference/functions/useStore.md
  • docs/framework/preact/reference/functions/useValue.md
  • docs/framework/preact/reference/index.md
  • docs/framework/preact/reference/interfaces/UseSelectorOptions.md
  • docs/framework/react/reference/functions/createStoreContext.md
  • docs/framework/react/reference/functions/useAtom.md
  • docs/framework/react/reference/functions/useCreateAtom.md
  • docs/framework/react/reference/functions/useCreateStore.md
  • docs/framework/react/reference/functions/useSelector.md
  • docs/framework/react/reference/functions/useStore-1.md
  • docs/framework/react/reference/functions/useStore.md
  • docs/framework/react/reference/functions/useValue.md
  • docs/framework/react/reference/index.md
  • docs/framework/react/reference/interfaces/UseSelectorOptions.md
  • docs/framework/solid/quick-start.md
  • docs/framework/solid/reference/functions/shallow.md
  • docs/framework/solid/reference/functions/useAtom.md
  • docs/framework/solid/reference/functions/useSelector.md
  • docs/framework/solid/reference/functions/useStore-1.md
  • docs/framework/solid/reference/functions/useStore.md
  • docs/framework/solid/reference/functions/useValue.md
  • docs/framework/solid/reference/index.md
  • docs/framework/solid/reference/interfaces/UseSelectorOptions.md
  • docs/framework/svelte/quick-start.md
  • docs/framework/svelte/reference/functions/shallow.md
  • docs/framework/svelte/reference/functions/useAtom.md
  • docs/framework/svelte/reference/functions/useSelector.md
  • docs/framework/svelte/reference/functions/useStore-1.md
  • docs/framework/svelte/reference/functions/useStore.md
  • docs/framework/svelte/reference/functions/useValue.md
  • docs/framework/svelte/reference/index.md
  • docs/framework/svelte/reference/interfaces/UseSelectorOptions.md
  • docs/framework/vue/quick-start.md
  • docs/framework/vue/reference/functions/useAtom.md
  • docs/framework/vue/reference/functions/useSelector.md
  • docs/framework/vue/reference/functions/useStore-1.md
  • docs/framework/vue/reference/functions/useStore.md
  • docs/framework/vue/reference/functions/useValue.md
  • docs/framework/vue/reference/index.md
  • docs/framework/vue/reference/interfaces/UseSelectorOptions.md
  • docs/reference/classes/ReadonlyStore.md
  • docs/reference/classes/Store.md
  • docs/reference/functions/createStore.md
  • docs/reference/functions/shallow.md
  • docs/reference/index.md
  • docs/reference/type-aliases/StoreAction.md
  • docs/reference/type-aliases/StoreActionMap.md
  • docs/reference/type-aliases/StoreActionsFactory.md
  • examples/angular/atoms/README.md
  • examples/angular/atoms/angular.json
  • examples/angular/atoms/package.json
  • examples/angular/atoms/src/app/app.component.ts
  • examples/angular/atoms/src/index.html
  • examples/angular/atoms/src/main.ts
  • examples/angular/atoms/tsconfig.app.json
  • examples/angular/atoms/tsconfig.json
  • examples/angular/atoms/tsconfig.spec.json
  • examples/angular/simple/README.md
  • examples/angular/simple/src/app/display.component.ts
  • examples/angular/simple/src/app/store.ts
  • examples/angular/store-actions/README.md
  • examples/angular/store-actions/angular.json
  • examples/angular/store-actions/package.json
  • examples/angular/store-actions/src/app/app.component.ts
  • examples/angular/store-actions/src/index.html
  • examples/angular/store-actions/src/main.ts
  • examples/angular/store-actions/tsconfig.app.json
  • examples/angular/store-actions/tsconfig.json
  • examples/angular/store-actions/tsconfig.spec.json
  • examples/angular/store-context/README.md
  • examples/angular/store-context/angular.json
  • examples/angular/store-context/package.json
  • examples/angular/store-context/src/app/app.component.ts
  • examples/angular/store-context/src/index.html
  • examples/angular/store-context/src/main.ts
  • examples/angular/store-context/tsconfig.app.json
  • examples/angular/store-context/tsconfig.json
  • examples/angular/store-context/tsconfig.spec.json
  • examples/angular/stores/README.md
  • examples/angular/stores/angular.json
  • examples/angular/stores/package.json
  • examples/angular/stores/src/app/app.component.ts
  • examples/angular/stores/src/index.html
  • examples/angular/stores/src/main.ts
  • examples/angular/stores/tsconfig.app.json
  • examples/angular/stores/tsconfig.json
  • examples/angular/stores/tsconfig.spec.json
  • examples/preact/atoms/README.md
  • examples/preact/atoms/index.html
  • examples/preact/atoms/package.json
  • examples/preact/atoms/src/index.tsx
  • examples/preact/atoms/tsconfig.json
  • examples/preact/atoms/vite.config.ts
  • examples/preact/simple/README.md
  • examples/preact/simple/src/index.tsx
  • examples/preact/simple/tsconfig.json
  • examples/preact/store-actions/README.md
  • examples/preact/store-actions/index.html
  • examples/preact/store-actions/package.json
  • examples/preact/store-actions/src/index.tsx
  • examples/preact/store-actions/tsconfig.json
  • examples/preact/store-actions/vite.config.ts
  • examples/preact/store-context/README.md
  • examples/preact/store-context/index.html
  • examples/preact/store-context/package.json
  • examples/preact/store-context/src/index.tsx
  • examples/preact/store-context/tsconfig.json
  • examples/preact/store-context/vite.config.ts
  • examples/preact/stores/README.md
  • examples/preact/stores/index.html
  • examples/preact/stores/package.json
  • examples/preact/stores/src/index.tsx
  • examples/preact/stores/tsconfig.json
  • examples/preact/stores/vite.config.ts
  • examples/react/atoms/src/index.tsx
  • examples/react/simple/src/index.tsx
  • examples/react/store-actions/README.md
  • examples/react/store-actions/index.html
  • examples/react/store-actions/package.json
  • examples/react/store-actions/src/index.tsx
  • examples/react/store-actions/tsconfig.json
  • examples/react/store-context/src/index.tsx
  • examples/react/stores/README.md
  • examples/react/stores/src/index.tsx
  • examples/solid/atoms/README.md
  • examples/solid/atoms/index.html
  • examples/solid/atoms/package.json
  • examples/solid/atoms/src/index.tsx
  • examples/solid/atoms/tsconfig.json
  • examples/solid/atoms/vite.config.ts
  • examples/solid/simple/README.md
  • examples/solid/simple/src/index.tsx
  • examples/solid/store-actions/README.md
  • examples/solid/store-actions/index.html
  • examples/solid/store-actions/package.json
  • examples/solid/store-actions/src/index.tsx
  • examples/solid/store-actions/tsconfig.json
  • examples/solid/store-actions/vite.config.ts
  • examples/solid/store-context/README.md
  • examples/solid/store-context/index.html
  • examples/solid/store-context/package.json
  • examples/solid/store-context/src/index.tsx
  • examples/solid/store-context/tsconfig.json
  • examples/solid/store-context/vite.config.ts
  • examples/solid/stores/README.md
  • examples/solid/stores/index.html
  • examples/solid/stores/package.json
  • examples/solid/stores/src/index.tsx
  • examples/solid/stores/tsconfig.json
  • examples/solid/stores/vite.config.ts
  • examples/svelte/atoms/README.md
  • examples/svelte/atoms/index.html
  • examples/svelte/atoms/package.json
  • examples/svelte/atoms/src/App.svelte
  • examples/svelte/atoms/src/main.ts
  • examples/svelte/atoms/src/vite-env.d.ts
  • examples/svelte/atoms/svelte.config.js
  • examples/svelte/atoms/tsconfig.json
  • examples/svelte/atoms/tsconfig.node.json
  • examples/svelte/atoms/vite.config.ts
  • examples/svelte/simple/README.md
  • examples/svelte/simple/src/Display.svelte
  • examples/svelte/simple/src/store.ts
  • examples/svelte/store-actions/README.md
  • examples/svelte/store-actions/index.html
  • examples/svelte/store-actions/package.json
  • examples/svelte/store-actions/src/App.svelte
  • examples/svelte/store-actions/src/main.ts
  • examples/svelte/store-actions/src/vite-env.d.ts
  • examples/svelte/store-actions/svelte.config.js
  • examples/svelte/store-actions/tsconfig.json
  • examples/svelte/store-actions/tsconfig.node.json
  • examples/svelte/store-actions/vite.config.ts
  • examples/svelte/store-context/README.md
  • examples/svelte/store-context/index.html
  • examples/svelte/store-context/package.json
  • examples/svelte/store-context/src/App.svelte
  • examples/svelte/store-context/src/AtomSection.svelte
  • examples/svelte/store-context/src/StoreSection.svelte
  • examples/svelte/store-context/src/context.ts
  • examples/svelte/store-context/src/main.ts
  • examples/svelte/store-context/src/vite-env.d.ts
  • examples/svelte/store-context/svelte.config.js
  • examples/svelte/store-context/tsconfig.json
  • examples/svelte/store-context/tsconfig.node.json
  • examples/svelte/store-context/vite.config.ts
  • examples/svelte/stores/README.md
  • examples/svelte/stores/index.html
  • examples/svelte/stores/package.json
  • examples/svelte/stores/src/App.svelte
  • examples/svelte/stores/src/main.ts
  • examples/svelte/stores/src/vite-env.d.ts
  • examples/svelte/stores/svelte.config.js
  • examples/svelte/stores/tsconfig.json
  • examples/svelte/stores/tsconfig.node.json
  • examples/svelte/stores/vite.config.ts
  • examples/vue/atoms/README.md
  • examples/vue/atoms/index.html
  • examples/vue/atoms/package.json
  • examples/vue/atoms/src/App.vue
  • examples/vue/atoms/src/main.ts
  • examples/vue/atoms/src/shims-vue.d.ts
  • examples/vue/atoms/tsconfig.json
  • examples/vue/atoms/vite.config.ts
  • examples/vue/simple/README.md
  • examples/vue/simple/src/Display.vue
  • examples/vue/simple/src/store.ts
  • examples/vue/store-actions/README.md
  • examples/vue/store-actions/index.html
  • examples/vue/store-actions/package.json
  • examples/vue/store-actions/src/App.vue
  • examples/vue/store-actions/src/main.ts
  • examples/vue/store-actions/src/shims-vue.d.ts
  • examples/vue/store-actions/tsconfig.json
  • examples/vue/store-actions/vite.config.ts
  • examples/vue/store-context/README.md
  • examples/vue/store-context/index.html
  • examples/vue/store-context/package.json
  • examples/vue/store-context/src/App.vue
  • examples/vue/store-context/src/main.ts
  • examples/vue/store-context/src/shims-vue.d.ts
  • examples/vue/store-context/tsconfig.json
  • examples/vue/store-context/vite.config.ts
  • examples/vue/stores/README.md
  • examples/vue/stores/index.html
  • examples/vue/stores/package.json
  • examples/vue/stores/src/App.vue
  • examples/vue/stores/src/main.ts
  • examples/vue/stores/src/shims-vue.d.ts
  • examples/vue/stores/tsconfig.json
  • examples/vue/stores/vite.config.ts
  • packages/angular-store/src/_injectStore.ts
  • packages/angular-store/src/createStoreContext.ts
  • packages/angular-store/src/index.ts
  • packages/angular-store/src/injectAtom.ts
  • packages/angular-store/src/injectSelector.ts
  • packages/angular-store/src/injectStore.ts
  • packages/angular-store/src/injectValue.ts
  • packages/angular-store/tests/index.test.ts
  • packages/angular-store/tests/test.test-d.ts
  • packages/preact-store/src/_useStore.ts
  • packages/preact-store/src/createStoreContext.tsx
  • packages/preact-store/src/index.ts
  • packages/preact-store/src/useAtom.ts
  • packages/preact-store/src/useCreateAtom.ts
  • packages/preact-store/src/useCreateStore.ts
  • packages/preact-store/src/useSelector.ts
  • packages/preact-store/src/useStore.ts
  • packages/preact-store/src/useValue.ts
  • packages/preact-store/tests/index.test.tsx
  • packages/preact-store/tests/test.test-d.ts
  • packages/react-store/src/_useStore.ts

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a set of React hooks and context utilities for TanStack Store (useSelector, useValue, useSetValue, useAtom, useCreateAtom, useCreateStore, createStoreContext), extracts/refactors shallow and useStore (deprecated alias), updates docs, examples, package exports, and expands tests.

Changes

Cohort / File(s) Summary
Changeset Entry
.changeset/petite-actors-lie.md
New changeset marking minor version bumps and build/process notes.
React API docs & nav
docs/config.json, docs/framework/react/reference/index.md, docs/framework/react/reference/functions/*.md, docs/framework/react/reference/interfaces/UseSelectorOptions.md, docs/framework/react/quick-start.md
Adds docs for new hooks/interfaces, updates navigation to replace/useSelector for useStore, marks useStore deprecated, and updates quick-start examples.
React examples (new)
examples/react/atoms/..., examples/react/stores/..., examples/react/store-context/...
Adds three React example projects demonstrating atom hooks, store hooks, and store-context usage (entrypoints, package.json, tsconfigs, HTML).
React examples (updated)
examples/react/simple/*, examples/*/simple/package.json, examples/*/simple/angular.json
Standardizes dev ports to 3050, replaces useStore with useSelector in simple React example, removes react-scan where applicable, and adjusts framework example configs.
React runtime - new hooks & context
packages/react-store/src/useSelector.ts, useValue.ts, useSetValue.ts, useAtom.ts, useCreateAtom.ts, useCreateStore.ts, createRequiredContext.ts, createStoreContext.ts
Implements new hooks and a typed store-context factory: selection, whole-value read, stable setters, combined read/write atom hook, and mount-stable atom/store creation; adds required-context helper.
Refactor exports & utilities
packages/react-store/src/index.ts, packages/react-store/src/useStore.ts, packages/react-store/src/shallow.ts
Reworks barrel exports to expose new hooks, moves shallow into its own module, and turns useStore into a deprecated wrapper forwarding to useSelector.
Tests & types
packages/react-store/tests/index.test.tsx, packages/react-store/tests/test.test-d.ts
Substantially expands runtime and type tests to cover the new hooks, context behavior, readonly vs writable variants, and useStore compatibility.
Package metadata / build
package.json, packages/*-store/package.json (react, vue, preact, solid, angular, store, etc.)
Updates dev dependency versions, changes published types paths to .d.cts, and simplifies package exports mappings (remove conditional types entries).

Sequence Diagram(s)

sequenceDiagram
    participant App as React App
    participant Provider as StoreProvider
    participant Context as StoreContext
    participant Component as Component
    participant Source as Atom/Store

    App->>Provider: create store/atom via useCreateStore/useCreateAtom
    App->>Provider: wrap children with StoreProvider(value)
    Provider->>Context: provide keyed value ({ store, atom })
    Component->>Context: useStoreContext()
    Context-->>Component: returns { store, atom }
    Component->>Source: useSelector(source, selector) / useValue(source)
    Source-->>Component: selected or full value
    Component->>Source: useSetValue(source) / useAtom(source)
    Source-->>Component: returns stable setter / [value, setter]
    Component->>Source: invoke setter -> update
    Source->>Component: subscription triggers re-render with new value
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • crutchcorn

Poem

🐰 Hopped in code with eager paws,

I stitched new hooks and trimmed old laws,
Context baskets, selectors bright,
Setters steady, types just right,
I nibble bugs and celebrate the PR’s applause!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.28% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: new hooks and actions APIs' accurately describes the main changes: multiple new React hooks (useValue, useSetValue, useAtom, useSelector, useCreateAtom, useCreateStore) and createStoreContext API additions.
Description check ✅ Passed Pull request provides comprehensive details about changes across all packages and includes both checklist completion and release impact declaration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hooks

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 11, 2026

View your CI Pipeline Execution ↗ for commit 44daa4c

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 31s View ↗
nx run-many --target=build --exclude=examples/** ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-14 23:24:55 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 11, 2026

🚀 Changeset Version Preview

7 package(s) bumped directly, 0 bumped as dependents.

🟨 Minor bumps

Package Version Reason
@tanstack/angular-store 0.10.0 → 0.11.0 Changeset
@tanstack/preact-store 0.12.0 → 0.13.0 Changeset
@tanstack/react-store 0.10.0 → 0.11.0 Changeset
@tanstack/solid-store 0.10.0 → 0.11.0 Changeset
@tanstack/store 0.10.0 → 0.11.0 Changeset
@tanstack/svelte-store 0.11.0 → 0.12.0 Changeset
@tanstack/vue-store 0.10.0 → 0.11.0 Changeset

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 11, 2026

@tanstack/angular-store

npm i https://pkg.pr.new/@tanstack/angular-store@306

@tanstack/preact-store

npm i https://pkg.pr.new/@tanstack/preact-store@306

@tanstack/react-store

npm i https://pkg.pr.new/@tanstack/react-store@306

@tanstack/solid-store

npm i https://pkg.pr.new/@tanstack/solid-store@306

@tanstack/store

npm i https://pkg.pr.new/@tanstack/store@306

@tanstack/svelte-store

npm i https://pkg.pr.new/@tanstack/svelte-store@306

@tanstack/vue-store

npm i https://pkg.pr.new/@tanstack/vue-store@306

commit: 44daa4c

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

🧹 Nitpick comments (1)
packages/react-store/src/createRequiredContext.ts (1)

4-25: Consider making context name configurable for reusable diagnostics.

The helper is generic, but the current error/display name are store-specific. Parameterizing the name would keep future usage messages accurate.

Possible refactor
-export function createRequiredContext<TValue>() {
+export function createRequiredContext<TValue>(contextName = 'StoreContext') {
   const Context = createContext<TValue | null>(null)
-  Context.displayName = 'StoreContext'
+  Context.displayName = contextName
@@
     if (value === null) {
-      throw new Error('Missing StoreProvider for StoreContext')
+      throw new Error(`Missing Provider for ${contextName}`)
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react-store/src/createRequiredContext.ts` around lines 4 - 25,
Change createRequiredContext to accept an optional context name parameter (e.g.,
createRequiredContext<TValue>(contextName = 'StoreContext')) and use that
parameter to set Context.displayName and to build the thrown error in
useRequiredValue; update references to Context.displayName and the error message
string ("Missing StoreProvider for StoreContext") to interpolate the provided
contextName so diagnostics reflect the caller-provided name, and keep Provider
and useRequiredValue behavior the same.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/petite-actors-lie.md:
- Around line 2-11: The changeset .changeset/petite-actors-lie.md currently
lists blanket minor bumps for many framework packages and a generic message
("chore: update deps and change build process to tsdown") that doesn't match the
PR's "new React hooks" feature; update the changeset to either (a) limit the
package entries to only the affected package(s) (e.g., '@tanstack/react-store')
and change the message to describe the new React hooks, or (b) split into two
changesets—one describing the new React hooks for the React package and a
separate one for dependency/build changes—so release notes and version bumps
accurately reflect the feature scope.

In `@docs/framework/react/reference/functions/createStoreContext.md`:
- Around line 9-33: Docs currently show createStoreContext<TValue>(): object but
the implementation requires TValue extends object and returns a typed store
context provider object; update the doc signature to declare the generic
constraint (TValue extends object) and replace the vague return type "object"
with the precise typed context return (reference the createStoreContext function
and the StoreProvider it returns, and mention
useStoreContext/useSelector/useValue hooks so readers see the linkage) so the
docs match the implementation's API contract.

In `@docs/framework/react/reference/functions/useCreateAtom.md`:
- Line 48: The markdown contains a duplicated heading "## Call Signature" for
useCreateAtom which triggers MD024; edit the second occurrence so it is unique
(e.g., change it to "## Call Signature (overload 2)" or "## Call Signature —
Overload 2") to avoid duplicate-heading lint warnings while preserving the
overload content for the useCreateAtom documentation.

In `@docs/framework/react/reference/functions/useCreateStore.md`:
- Around line 8-44: The docs have duplicate "## Call Signature" headings which
triggers MD024; edit the useCreateStore documentation so each overload section
has a unique heading (e.g., rename one to "## Call Signatures" or "## Call
Signature (overload)" or similar), ensuring the references to the function
useCreateStore and the content under the original first block remain unchanged
and only the trailing duplicate heading is renamed or removed to eliminate the
duplicate heading conflict.

In `@docs/framework/react/reference/functions/useSetValue.md`:
- Line 50: The docs file has duplicate "## Call Signature" headings for the
useSetValue function which can trigger markdownlint MD024; update the second
overload heading to a unique label (e.g., "## Call Signature (overload 2)" or
"## Call Signature — overloaded") so the overload sections for useSetValue are
distinct and avoid the lint rule.

In `@examples/react/atoms/index.html`:
- Line 10: Replace the unversioned CDN script URL in the HTML (the <script
src="https://unpkg.com/react-scan/dist/auto.global.js"> tag) with a pinned
package version and add Subresource Integrity and crossorigin attributes; e.g.,
change the src to include a specific version like react-scan@0.3.4, fetch the
integrity value from https://unpkg.com/react-scan@0.3.4/dist/auto.global.js?meta
and add integrity="..." and crossorigin="anonymous" to the script tag to prevent
tampering and unexpected updates.

In `@examples/react/atoms/src/index.tsx`:
- Around line 2-8: The import mixes a type with value imports which violates
import/consistent-type-specifier-style; separate the type import from runtime
imports by creating a dedicated type-only import for Atom (e.g., import type {
Atom } from '@tanstack/react-store') and keep useAtom, useCreateAtom,
useSetValue, useValue in a separate non-type import from '@tanstack/react-store'
so the type and value imports are in distinct statements.

In `@examples/react/simple/index.html`:
- Line 14: Update the floating CDN import script tag (the line with
src="https://unpkg.com/react-scan/dist/auto.global.js") to pin to
react-scan@0.5.3 by changing the src to
https://unpkg.com/react-scan@0.5.3/dist/auto.global.js and add an integrity
attribute containing the correct SRI hash for that exact file plus
crossorigin="anonymous"; obtain the precise SRI (sha256/sha384/sha512) from the
published artifact or a trusted SRI tool and paste it into the integrity
attribute so the script tag includes both integrity="..." and
crossorigin="anonymous".

In `@examples/react/store-context/src/index.tsx`:
- Around line 2-10: The import list from '@tanstack/react-store' is not
alphabetized (violates sort-imports); reorder the named imports so
createStoreContext appears first and the rest follow alphabetically (e.g.,
createStoreContext, useAtom, useCreateAtom, useCreateStore, useSelector,
useSetValue, useValue) to satisfy the linter rule and keep the import statement
consistent.

In `@examples/react/stores/src/index.tsx`:
- Line 2: Change the mixed import to use a top-level type-only import for the
Store type: import type { Store } separately and keep the runtime imports
(useCreateStore, useSelector) as normal imports; update the import statement(s)
in index.tsx so Store is imported with the `import type` form to satisfy
import/consistent-type-specifier-style while leaving useCreateStore and
useSelector as runtime imports.

---

Nitpick comments:
In `@packages/react-store/src/createRequiredContext.ts`:
- Around line 4-25: Change createRequiredContext to accept an optional context
name parameter (e.g., createRequiredContext<TValue>(contextName =
'StoreContext')) and use that parameter to set Context.displayName and to build
the thrown error in useRequiredValue; update references to Context.displayName
and the error message string ("Missing StoreProvider for StoreContext") to
interpolate the provided contextName so diagnostics reflect the caller-provided
name, and keep Provider and useRequiredValue behavior the same.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 23a04a85-8c1a-486d-a0d5-e429944d1e62

📥 Commits

Reviewing files that changed from the base of the PR and between 840b9d0 and 154e0a8.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (52)
  • .changeset/petite-actors-lie.md
  • docs/config.json
  • docs/framework/react/quick-start.md
  • docs/framework/react/reference/functions/createStoreContext.md
  • docs/framework/react/reference/functions/shallow.md
  • docs/framework/react/reference/functions/useAtom.md
  • docs/framework/react/reference/functions/useCreateAtom.md
  • docs/framework/react/reference/functions/useCreateStore.md
  • docs/framework/react/reference/functions/useSelector.md
  • docs/framework/react/reference/functions/useSetValue.md
  • docs/framework/react/reference/functions/useStore.md
  • docs/framework/react/reference/functions/useValue.md
  • docs/framework/react/reference/index.md
  • docs/framework/react/reference/interfaces/UseSelectorOptions.md
  • examples/angular/simple/angular.json
  • examples/preact/simple/package.json
  • examples/react/atoms/README.md
  • examples/react/atoms/index.html
  • examples/react/atoms/package.json
  • examples/react/atoms/src/index.tsx
  • examples/react/atoms/tsconfig.json
  • examples/react/simple/index.html
  • examples/react/simple/package.json
  • examples/react/simple/src/index.tsx
  • examples/react/store-context/README.md
  • examples/react/store-context/index.html
  • examples/react/store-context/package.json
  • examples/react/store-context/src/index.tsx
  • examples/react/store-context/src/vite-env.d.ts
  • examples/react/store-context/tsconfig.json
  • examples/react/store-context/vite.config.ts
  • examples/react/stores/README.md
  • examples/react/stores/index.html
  • examples/react/stores/package.json
  • examples/react/stores/src/index.tsx
  • examples/react/stores/tsconfig.json
  • examples/solid/simple/package.json
  • examples/svelte/simple/package.json
  • examples/vue/simple/package.json
  • packages/react-store/src/createRequiredContext.ts
  • packages/react-store/src/createStoreContext.ts
  • packages/react-store/src/index.ts
  • packages/react-store/src/shallow.ts
  • packages/react-store/src/useAtom.ts
  • packages/react-store/src/useCreateAtom.ts
  • packages/react-store/src/useCreateStore.ts
  • packages/react-store/src/useSelector.ts
  • packages/react-store/src/useSetValue.ts
  • packages/react-store/src/useStore.ts
  • packages/react-store/src/useValue.ts
  • packages/react-store/tests/index.test.tsx
  • packages/react-store/tests/test.test-d.ts

Comment thread .changeset/petite-actors-lie.md
Comment thread docs/framework/react/reference/functions/createStoreContext.md
Comment thread docs/framework/react/reference/functions/useCreateAtom.md
Comment thread docs/framework/react/reference/functions/useCreateStore.md
Comment thread docs/framework/react/reference/functions/useSetValue.md Outdated
Comment thread examples/react/atoms/index.html
Comment thread examples/react/atoms/src/index.tsx
Comment thread examples/react/simple/index.html
Comment thread examples/react/store-context/src/index.tsx
Comment thread examples/react/stores/src/index.tsx Outdated
* feat: add actions to stores

* ci: apply automated fixes and generate docs

* simplify context hook impl

* ci: apply automated fixes and generate docs

* feat: introduce more frameworks hooks for other non-react adapters (#308)

* feat: introduce more frameworks hooks for other non-react adapters

* new changeset

* ci: apply automated fixes and generate docs

* remove dedicated setValue and useAction hooks. Add new useStore hooks with _

* ci: apply automated fixes and generate docs

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
@KevinVandy KevinVandy changed the title feat: new react hooks feat: new hooks and actions APIs Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant