destructurable<TProps extends Record<string | symbol, any>,TDefaultProps extends DefaultProps<TProps> = NonNullable<unknown>,>(props: TProps,defaultProps?: TDefaultProps,): DestructurableProps<TProps, TDefaultProps>
Returns a destructurable object
▶Example 1
Example 1
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> ) }
TProps extends Record<string | symbol, any>
TDefaultProps extends DefaultProps<TProps> = NonNullable<unknown>
props: TProps
optional
defaultProps: TDefaultProps