@umpire/tanstack-store
v1.0.0
Published
TanStack Store adapter for @umpire/core built on @umpire/store
Readme
@umpire/tanstack-store
TanStack Store adapter for Umpire. It snapshots previous .state, then delegates to @umpire/store.
Install
npm install @umpire/tanstack-store @umpire/core @tanstack/storeUsage
import { createStore } from '@tanstack/store'
import { enabledWhen, umpire } from '@umpire/core'
import { fromTanStackStore } from '@umpire/tanstack-store'
const ump = umpire({
fields: {
password: {},
confirmPassword: { default: '' },
},
rules: [
enabledWhen('confirmPassword', (values) => {
return (values.password as string)?.length > 0
}),
],
})
const store = createStore({
password: '',
confirmPassword: '',
})
const umpStore = fromTanStackStore(ump, store, {
select: (state) => ({
password: state.password,
confirmPassword: state.confirmPassword,
}),
})