Skip to main content
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
82%
Published
3 months ago (0.0.2)
function destructurable
destructurable<
TProps extends Record<string | symbol, any>,
TDefaultProps extends DefaultProps<TProps> = NonNullable<unknown>,
>
(
props: TProps,
defaultProps?: TDefaultProps,
): DestructurableProps<TProps, TDefaultProps>

Returns a destructurable object

Examples

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>
	)
}

Type Parameters

TProps extends Record<string | symbol, any>
TDefaultProps extends DefaultProps<TProps> = NonNullable<unknown>

Parameters

props: TProps
optional
defaultProps: TDefaultProps

Return Type

Add Package

deno add @vyke/solid-destructurable

Import symbol

import { destructurable } from "@vyke/solid-destructurable";

Add Package

npx jsr add @vyke/solid-destructurable

Import symbol

import { destructurable } from "@vyke/solid-destructurable";

Add Package

yarn dlx jsr add @vyke/solid-destructurable

Import symbol

import { destructurable } from "@vyke/solid-destructurable";

Add Package

pnpm dlx jsr add @vyke/solid-destructurable

Import symbol

import { destructurable } from "@vyke/solid-destructurable";

Add Package

bunx jsr add @vyke/solid-destructurable

Import symbol

import { destructurable } from "@vyke/solid-destructurable";