@vyke/solid-destructurable
v0.0.2
Published
Helper to destructure reactive objects - like props or stores - or signals of them into a separate accessors updated individually.
Downloads
2
Readme
Installation
npm i @vyke/solid-destructurable
API
destructurable
Returns a destructurable object
import { createStore } from 'solid-js'
import { destructurable } from '@vyke/solid-destructurable'
type StoreState = {
theme?: 'light' | 'dark'
}
type AppProps = {
title: string
}
function App(props: AppProps) {
const { title } = destructurable(props)
const store = createStore<StoreState>({ theme: 'light' })
const { theme } = destructurable(store, { theme: 'dark' })
return (
<div>
{title()}
{theme()}
</div>
)
}