createRouteAction
createRouteAction
creates a controller for managing the submissions of an async user action
tsx
const [enrollingconst enrolling: {
pending: boolean;
input?: void | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
, enrollconst enroll: ((vars: void) => Promise<void>) & {
Form: never;
url: string;
}
] = createRouteAction(alias) createRouteAction<void, void>(fn: (arg1: void, event: ActionEvent) => Promise<void>, options?: {
invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined;
} | undefined): RouteAction<...> (+1 overload)
import createRouteAction
(enrollInClassfunction enrollInClass(): Promise<void>
)
tsx
const [enrollingconst enrolling: {
pending: boolean;
input?: void | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
, enrollconst enroll: ((vars: void) => Promise<void>) & {
Form: never;
url: string;
}
] = createRouteAction(alias) createRouteAction<void, void>(fn: (arg1: void, event: ActionEvent) => Promise<void>, options?: {
invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined;
} | undefined): RouteAction<...> (+1 overload)
import createRouteAction
(enrollInClassfunction enrollInClass(): Promise<void>
)
Usage
While you might think this should be just a straight forward onClick
handler, there are a few things to consider. You would want to show indicators of the action being performed. You would want to handle errors. You may also want to handle multiple submissions. Lets see how createRouteAction
helps you deal with some of these issues.
Show a pending indicator for an action in progress
We want to show a pending status while the action is being performed. The submission has a pending
property that we can use to show a pending indicator.
tsx
import { createRouteAction(alias) function createRouteAction<T = void, U = void>(fn: (arg1: void, event: ActionEvent) => Promise<U>, options?: {
invalidate?: string | any[] | ((r: Response) => string | any[] | void) | undefined;
} | undefined): RouteAction<T, U> (+1 overload)
import createRouteAction
} from 'solid-start' import { ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
} from 'solid-js' Â
Â
function EnrollmentPagefunction EnrollmentPage(): JSX.Element
() { const [enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
, enrollconst enroll: ((vars: string) => Promise<void>) & {
Form: never;
url: string;
}
] = createRouteAction(alias) createRouteAction<string, void>(fn: (args: string, event: ActionEvent) => Promise<void>, options?: {
invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined;
} | undefined): RouteAction<...> (+1 overload)
import createRouteAction
(enrollInClassfunction enrollInClass(className: string): Promise<void>
) return (
<div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> <button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
onClick(property) JSX.DOMAttributes<HTMLButtonElement>.onClick?: JSX.EventHandlerUnion<HTMLButtonElement, MouseEvent> | undefined
={() => enrollconst enroll: (vars: string) => Promise<void>
('Defense against the Dark Arts')} disabled(property) JSX.ButtonHTMLAttributes<HTMLButtonElement>.disabled?: boolean | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
} >
Enroll
</button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when(property) when: boolean | null | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>Enrolling...</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> </div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> )
}
Â
tsx
import { createRouteAction(alias) function createRouteAction<T = void, U = void>(fn: (arg1: void, event: ActionEvent) => Promise<U>, options?: {
invalidate?: string | any[] | ((r: Response) => string | any[] | void) | undefined;
} | undefined): RouteAction<T, U> (+1 overload)
import createRouteAction
} from 'solid-start' import { ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
} from 'solid-js' Â
Â
function EnrollmentPagefunction EnrollmentPage(): JSX.Element
() { const [enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
, enrollconst enroll: ((vars: string) => Promise<void>) & {
Form: never;
url: string;
}
] = createRouteAction(alias) createRouteAction<string, void>(fn: (args: string, event: ActionEvent) => Promise<void>, options?: {
invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined;
} | undefined): RouteAction<...> (+1 overload)
import createRouteAction
(enrollInClassfunction enrollInClass(className: string): Promise<void>
) return (
<div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> <button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
onClick(property) JSX.DOMAttributes<HTMLButtonElement>.onClick?: JSX.EventHandlerUnion<HTMLButtonElement, MouseEvent> | undefined
={() => enrollconst enroll: (vars: string) => Promise<void>
('Defense against the Dark Arts')} disabled(property) JSX.ButtonHTMLAttributes<HTMLButtonElement>.disabled?: boolean | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
} >
Enroll
</button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when(property) when: boolean | null | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>Enrolling...</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> </div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> )
}
Â
Handle errors
If an error occurs, the submission will have an error
property. We can use this to show an error message.
routes/enrollment.tsx
tsx
import { createRouteAction(alias) function createRouteAction<T = void, U = void>(fn: (arg1: void, event: ActionEvent) => Promise<U>, options?: {
invalidate?: string | any[] | ((r: Response) => string | any[] | void) | undefined;
} | undefined): RouteAction<T, U> (+1 overload)
import createRouteAction
} from 'solid-start' import { ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
} from 'solid-js' Â
export default function EnrollmentPagefunction EnrollmentPage(): JSX.Element
() { const [enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
, enrollconst enroll: ((vars: string) => Promise<void>) & {
Form: never;
url: string;
}
] = createRouteAction(alias) createRouteAction<string, void>(fn: (args: string, event: ActionEvent) => Promise<void>, options?: {
invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined;
} | undefined): RouteAction<...> (+1 overload)
import createRouteAction
(enrollInClassfunction enrollInClass(className: string): Promise<void>
) return (
<div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> <button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
onClick(property) JSX.DOMAttributes<HTMLButtonElement>.onClick?: JSX.EventHandlerUnion<HTMLButtonElement, MouseEvent> | undefined
={() => enrollconst enroll: (vars: string) => Promise<void>
('Defense against the Dark Arts')} disabled(property) JSX.ButtonHTMLAttributes<HTMLButtonElement>.disabled?: boolean | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
} >
Enroll
</button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when(property) when: boolean | null | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>Enrolling...</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.error}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>{enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.error.message}</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> </div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> )
}
routes/enrollment.tsx
tsx
import { createRouteAction(alias) function createRouteAction<T = void, U = void>(fn: (arg1: void, event: ActionEvent) => Promise<U>, options?: {
invalidate?: string | any[] | ((r: Response) => string | any[] | void) | undefined;
} | undefined): RouteAction<T, U> (+1 overload)
import createRouteAction
} from 'solid-start' import { ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
} from 'solid-js' Â
export default function EnrollmentPagefunction EnrollmentPage(): JSX.Element
() { const [enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
, enrollconst enroll: ((vars: string) => Promise<void>) & {
Form: never;
url: string;
}
] = createRouteAction(alias) createRouteAction<string, void>(fn: (args: string, event: ActionEvent) => Promise<void>, options?: {
invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined;
} | undefined): RouteAction<...> (+1 overload)
import createRouteAction
(enrollInClassfunction enrollInClass(className: string): Promise<void>
) return (
<div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> <button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
onClick(property) JSX.DOMAttributes<HTMLButtonElement>.onClick?: JSX.EventHandlerUnion<HTMLButtonElement, MouseEvent> | undefined
={() => enrollconst enroll: (vars: string) => Promise<void>
('Defense against the Dark Arts')} disabled(property) JSX.ButtonHTMLAttributes<HTMLButtonElement>.disabled?: boolean | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
} >
Enroll
</button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when(property) when: boolean | null | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>Enrolling...</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.error}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>{enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.error.message}</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> </div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> )
}
Refetching data after an action
You don't have to do anything more to have your createRouteData
functions refetch data after an action. The createRouteData
functions will automatically refetch data after an action is performed.
Invalidating specific data after an action
If you don't want to refetch all the data, you can use the invalidate
param to specify which key
's to invalidate. This way you only refetch what you know has changed.
routes/enrollment.tsx
tsx
import { createRouteAction(alias) function createRouteAction<T = void, U = void>(fn: (arg1: void, event: ActionEvent) => Promise<U>, options?: {
invalidate?: string | any[] | ((r: Response) => string | any[] | void) | undefined;
} | undefined): RouteAction<T, U> (+1 overload)
import createRouteAction
, createRouteData(alias) function createRouteData<T, S = true>(fetcher: RouteDataFetcher<S, T>, options?: RouteDataOptions<undefined, S>): Resource<T | undefined> (+1 overload)
import createRouteData
} from 'solid-start' import { ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
, Forcreates a list elements from a list
it receives a map function as its child that receives a list element and an accessor with the index and returns a JSX-Element; if the list is empty, an optional fallback is returned:
```typescript
<For each={items} fallback={<div>No items</div>}>
{(item, index) => <div data-index={index()}>{item}</div>}
</For>
```
If you have a list with fixed indices and changing values, consider using `<Index>` instead.
(alias) function For<T, U extends JSX.Element>(props: {
each: readonly T[] | undefined | null | false;
fallback?: JSX.Element;
children: (item: T, index: Accessor<number>) => U;
}): Accessor<U[]>
import For
} from 'solid-js' Â
export default function EnrollmentPagefunction EnrollmentPage(): JSX.Element
() { const classesconst classes: Resource<{
name: string;
}[] | undefined>
= createRouteData(alias) createRouteData<{
name: string;
}[], string>(fetcher: RouteDataFetcher<string, {
name: string;
}[]>, options?: RouteDataOptions<undefined, string> | undefined): Resource<...> (+1 overload)
import createRouteData
(getClassesfunction getClasses(): Promise<{
name: string;
}[]>
, { key(property) key?: RouteDataSource<string>
: 'classes' }) const [enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
, enrollconst enroll: ((vars: string) => Promise<void>) & {
Form: never;
url: string;
}
] = createRouteAction(alias) createRouteAction<string, void>(fn: (args: string, event: ActionEvent) => Promise<void>, options?: {
invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined;
} | undefined): RouteAction<...> (+1 overload)
import createRouteAction
( enrollInClassfunction enrollInClass(className: string): Promise<void>
, { invalidate(property) invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined
: ['classes'] } )
Â
return (
<div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> <ul(property) JSX.IntrinsicElements.ul: JSX.HTMLAttributes<HTMLUListElement>
> <Forcreates a list elements from a list
it receives a map function as its child that receives a list element and an accessor with the index and returns a JSX-Element; if the list is empty, an optional fallback is returned:
```typescript
<For each={items} fallback={<div>No items</div>}>
{(item, index) => <div data-index={index()}>{item}</div>}
</For>
```
If you have a list with fixed indices and changing values, consider using `<Index>` instead.
(alias) function For<T, U extends JSX.Element>(props: {
each: readonly T[] | undefined | null | false;
fallback?: JSX.Element;
children: (item: T, index: Accessor<number>) => U;
}): Accessor<U[]>
import For
each(property) each: false | readonly {
name: string;
}[] | null | undefined
={classesconst classes: () => {
name: string;
}[] | undefined
()}> {course(parameter) course: {
name: string;
}
=> <li(property) JSX.IntrinsicElements.li: JSX.LiHTMLAttributes<HTMLLIElement>
>{course(parameter) course: {
name: string;
}
.name}</li(property) JSX.IntrinsicElements.li: JSX.LiHTMLAttributes<HTMLLIElement>
>} </Forcreates a list elements from a list
it receives a map function as its child that receives a list element and an accessor with the index and returns a JSX-Element; if the list is empty, an optional fallback is returned:
```typescript
<For each={items} fallback={<div>No items</div>}>
{(item, index) => <div data-index={index()}>{item}</div>}
</For>
```
If you have a list with fixed indices and changing values, consider using `<Index>` instead.
(alias) function For<T, U extends JSX.Element>(props: {
each: readonly T[] | undefined | null | false;
fallback?: JSX.Element;
children: (item: T, index: Accessor<number>) => U;
}): Accessor<U[]>
import For
> </ul(property) JSX.IntrinsicElements.ul: JSX.HTMLAttributes<HTMLUListElement>
> <button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
onClick(property) JSX.DOMAttributes<HTMLButtonElement>.onClick?: JSX.EventHandlerUnion<HTMLButtonElement, MouseEvent> | undefined
={() => enrollconst enroll: (vars: string) => Promise<void>
('Defense against the Dark Arts')} disabled(property) JSX.ButtonHTMLAttributes<HTMLButtonElement>.disabled?: boolean | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
} >
Enroll
</button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when(property) when: boolean | null | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>Enrolling...</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.error}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>{enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.error.message}</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> </div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> )
}
routes/enrollment.tsx
tsx
import { createRouteAction(alias) function createRouteAction<T = void, U = void>(fn: (arg1: void, event: ActionEvent) => Promise<U>, options?: {
invalidate?: string | any[] | ((r: Response) => string | any[] | void) | undefined;
} | undefined): RouteAction<T, U> (+1 overload)
import createRouteAction
, createRouteData(alias) function createRouteData<T, S = true>(fetcher: RouteDataFetcher<S, T>, options?: RouteDataOptions<undefined, S>): Resource<T | undefined> (+1 overload)
import createRouteData
} from 'solid-start' import { ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
, Forcreates a list elements from a list
it receives a map function as its child that receives a list element and an accessor with the index and returns a JSX-Element; if the list is empty, an optional fallback is returned:
```typescript
<For each={items} fallback={<div>No items</div>}>
{(item, index) => <div data-index={index()}>{item}</div>}
</For>
```
If you have a list with fixed indices and changing values, consider using `<Index>` instead.
(alias) function For<T, U extends JSX.Element>(props: {
each: readonly T[] | undefined | null | false;
fallback?: JSX.Element;
children: (item: T, index: Accessor<number>) => U;
}): Accessor<U[]>
import For
} from 'solid-js' Â
export default function EnrollmentPagefunction EnrollmentPage(): JSX.Element
() { const classesconst classes: Resource<{
name: string;
}[] | undefined>
= createRouteData(alias) createRouteData<{
name: string;
}[], string>(fetcher: RouteDataFetcher<string, {
name: string;
}[]>, options?: RouteDataOptions<undefined, string> | undefined): Resource<...> (+1 overload)
import createRouteData
(getClassesfunction getClasses(): Promise<{
name: string;
}[]>
, { key(property) key?: RouteDataSource<string>
: 'classes' }) const [enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
, enrollconst enroll: ((vars: string) => Promise<void>) & {
Form: never;
url: string;
}
] = createRouteAction(alias) createRouteAction<string, void>(fn: (args: string, event: ActionEvent) => Promise<void>, options?: {
invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined;
} | undefined): RouteAction<...> (+1 overload)
import createRouteAction
( enrollInClassfunction enrollInClass(className: string): Promise<void>
, { invalidate(property) invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined
: ['classes'] } )
Â
return (
<div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> <ul(property) JSX.IntrinsicElements.ul: JSX.HTMLAttributes<HTMLUListElement>
> <Forcreates a list elements from a list
it receives a map function as its child that receives a list element and an accessor with the index and returns a JSX-Element; if the list is empty, an optional fallback is returned:
```typescript
<For each={items} fallback={<div>No items</div>}>
{(item, index) => <div data-index={index()}>{item}</div>}
</For>
```
If you have a list with fixed indices and changing values, consider using `<Index>` instead.
(alias) function For<T, U extends JSX.Element>(props: {
each: readonly T[] | undefined | null | false;
fallback?: JSX.Element;
children: (item: T, index: Accessor<number>) => U;
}): Accessor<U[]>
import For
each(property) each: false | readonly {
name: string;
}[] | null | undefined
={classesconst classes: () => {
name: string;
}[] | undefined
()}> {course(parameter) course: {
name: string;
}
=> <li(property) JSX.IntrinsicElements.li: JSX.LiHTMLAttributes<HTMLLIElement>
>{course(parameter) course: {
name: string;
}
.name}</li(property) JSX.IntrinsicElements.li: JSX.LiHTMLAttributes<HTMLLIElement>
>} </Forcreates a list elements from a list
it receives a map function as its child that receives a list element and an accessor with the index and returns a JSX-Element; if the list is empty, an optional fallback is returned:
```typescript
<For each={items} fallback={<div>No items</div>}>
{(item, index) => <div data-index={index()}>{item}</div>}
</For>
```
If you have a list with fixed indices and changing values, consider using `<Index>` instead.
(alias) function For<T, U extends JSX.Element>(props: {
each: readonly T[] | undefined | null | false;
fallback?: JSX.Element;
children: (item: T, index: Accessor<number>) => U;
}): Accessor<U[]>
import For
> </ul(property) JSX.IntrinsicElements.ul: JSX.HTMLAttributes<HTMLUListElement>
> <button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
onClick(property) JSX.DOMAttributes<HTMLButtonElement>.onClick?: JSX.EventHandlerUnion<HTMLButtonElement, MouseEvent> | undefined
={() => enrollconst enroll: (vars: string) => Promise<void>
('Defense against the Dark Arts')} disabled(property) JSX.ButtonHTMLAttributes<HTMLButtonElement>.disabled?: boolean | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
} >
Enroll
</button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when(property) when: boolean | null | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>Enrolling...</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.error}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>{enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.error.message}</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> </div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> )
}
Optimistic UI
Now, since we have Javascript in our hands, we can give the user a more enhanced experience. Sometimes this means pretending an action was successful to provide a more response user experience. This is called an optimistic UI. We can do this in a neat way where you don't need to manage extra state. You have access to the input
on the submission, so you know what data was sent to the action. And using the pending
property, you can use the input
as part of the visible UI. For example, in a list of enrolled classes, you can add the class to the list before the action is complete. Then, if the action fails, you can remove the class from the list.
routes/enrollment.tsx
tsx
import { createRouteAction(alias) function createRouteAction<T = void, U = void>(fn: (arg1: void, event: ActionEvent) => Promise<U>, options?: {
invalidate?: string | any[] | ((r: Response) => string | any[] | void) | undefined;
} | undefined): RouteAction<T, U> (+1 overload)
import createRouteAction
, createRouteData(alias) function createRouteData<T, S = true>(fetcher: RouteDataFetcher<S, T>, options?: RouteDataOptions<undefined, S>): Resource<T | undefined> (+1 overload)
import createRouteData
} from 'solid-start' import { ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
, Forcreates a list elements from a list
it receives a map function as its child that receives a list element and an accessor with the index and returns a JSX-Element; if the list is empty, an optional fallback is returned:
```typescript
<For each={items} fallback={<div>No items</div>}>
{(item, index) => <div data-index={index()}>{item}</div>}
</For>
```
If you have a list with fixed indices and changing values, consider using `<Index>` instead.
(alias) function For<T, U extends JSX.Element>(props: {
each: readonly T[] | undefined | null | false;
fallback?: JSX.Element;
children: (item: T, index: Accessor<number>) => U;
}): Accessor<U[]>
import For
} from 'solid-js' Â
export function EnrollmentPagefunction EnrollmentPage(): JSX.Element
() { const classesconst classes: Resource<{
name: string;
}[] | undefined>
= createRouteData(alias) createRouteData<{
name: string;
}[], string>(fetcher: RouteDataFetcher<string, {
name: string;
}[]>, options?: RouteDataOptions<undefined, string> | undefined): Resource<...> (+1 overload)
import createRouteData
(getClassesfunction getClasses(): Promise<{
name: string;
}[]>
, { key(property) key?: RouteDataSource<string>
: 'classes' }) const [enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
, enrollconst enroll: ((vars: string) => Promise<void>) & {
Form: never;
url: string;
}
] = createRouteAction(alias) createRouteAction<string, void>(fn: (args: string, event: ActionEvent) => Promise<void>, options?: {
invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined;
} | undefined): RouteAction<...> (+1 overload)
import createRouteAction
( enrollInClassfunction enrollInClass(className: string): Promise<void>
, { invalidate(property) invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined
: ['classes'] } )
Â
return (
<div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> <ul(property) JSX.IntrinsicElements.ul: JSX.HTMLAttributes<HTMLUListElement>
> <Forcreates a list elements from a list
it receives a map function as its child that receives a list element and an accessor with the index and returns a JSX-Element; if the list is empty, an optional fallback is returned:
```typescript
<For each={items} fallback={<div>No items</div>}>
{(item, index) => <div data-index={index()}>{item}</div>}
</For>
```
If you have a list with fixed indices and changing values, consider using `<Index>` instead.
(alias) function For<T, U extends JSX.Element>(props: {
each: readonly T[] | undefined | null | false;
fallback?: JSX.Element;
children: (item: T, index: Accessor<number>) => U;
}): Accessor<U[]>
import For
each(property) each: false | readonly {
name: string;
}[] | null | undefined
={classesconst classes: () => {
name: string;
}[] | undefined
()}> {course(parameter) course: {
name: string;
}
=> <li(property) JSX.IntrinsicElements.li: JSX.LiHTMLAttributes<HTMLLIElement>
>{course(parameter) course: {
name: string;
}
.name}</li(property) JSX.IntrinsicElements.li: JSX.LiHTMLAttributes<HTMLLIElement>
>} </Forcreates a list elements from a list
it receives a map function as its child that receives a list element and an accessor with the index and returns a JSX-Element; if the list is empty, an optional fallback is returned:
```typescript
<For each={items} fallback={<div>No items</div>}>
{(item, index) => <div data-index={index()}>{item}</div>}
</For>
```
If you have a list with fixed indices and changing values, consider using `<Index>` instead.
(alias) function For<T, U extends JSX.Element>(props: {
each: readonly T[] | undefined | null | false;
fallback?: JSX.Element;
children: (item: T, index: Accessor<number>) => U;
}): Accessor<U[]>
import For
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when(property) when: boolean | null | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
}> <li(property) JSX.IntrinsicElements.li: JSX.LiHTMLAttributes<HTMLLIElement>
>{enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.input(property) input?: string | undefined
}</li(property) JSX.IntrinsicElements.li: JSX.LiHTMLAttributes<HTMLLIElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> </ul(property) JSX.IntrinsicElements.ul: JSX.HTMLAttributes<HTMLUListElement>
> <button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
onClick(property) JSX.DOMAttributes<HTMLButtonElement>.onClick?: JSX.EventHandlerUnion<HTMLButtonElement, MouseEvent> | undefined
={() => enrollconst enroll: (vars: string) => Promise<void>
('Defense against the Dark Arts')} disabled(property) JSX.ButtonHTMLAttributes<HTMLButtonElement>.disabled?: boolean | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
} >
Enroll
</button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when(property) when: boolean | null | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>Enrolling...</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.error}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>{enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.error.message}</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> </div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> )
}
routes/enrollment.tsx
tsx
import { createRouteAction(alias) function createRouteAction<T = void, U = void>(fn: (arg1: void, event: ActionEvent) => Promise<U>, options?: {
invalidate?: string | any[] | ((r: Response) => string | any[] | void) | undefined;
} | undefined): RouteAction<T, U> (+1 overload)
import createRouteAction
, createRouteData(alias) function createRouteData<T, S = true>(fetcher: RouteDataFetcher<S, T>, options?: RouteDataOptions<undefined, S>): Resource<T | undefined> (+1 overload)
import createRouteData
} from 'solid-start' import { ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
, Forcreates a list elements from a list
it receives a map function as its child that receives a list element and an accessor with the index and returns a JSX-Element; if the list is empty, an optional fallback is returned:
```typescript
<For each={items} fallback={<div>No items</div>}>
{(item, index) => <div data-index={index()}>{item}</div>}
</For>
```
If you have a list with fixed indices and changing values, consider using `<Index>` instead.
(alias) function For<T, U extends JSX.Element>(props: {
each: readonly T[] | undefined | null | false;
fallback?: JSX.Element;
children: (item: T, index: Accessor<number>) => U;
}): Accessor<U[]>
import For
} from 'solid-js' Â
export function EnrollmentPagefunction EnrollmentPage(): JSX.Element
() { const classesconst classes: Resource<{
name: string;
}[] | undefined>
= createRouteData(alias) createRouteData<{
name: string;
}[], string>(fetcher: RouteDataFetcher<string, {
name: string;
}[]>, options?: RouteDataOptions<undefined, string> | undefined): Resource<...> (+1 overload)
import createRouteData
(getClassesfunction getClasses(): Promise<{
name: string;
}[]>
, { key(property) key?: RouteDataSource<string>
: 'classes' }) const [enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
, enrollconst enroll: ((vars: string) => Promise<void>) & {
Form: never;
url: string;
}
] = createRouteAction(alias) createRouteAction<string, void>(fn: (args: string, event: ActionEvent) => Promise<void>, options?: {
invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined;
} | undefined): RouteAction<...> (+1 overload)
import createRouteAction
( enrollInClassfunction enrollInClass(className: string): Promise<void>
, { invalidate(property) invalidate?: string | any[] | ((r: Response) => string | void | any[]) | undefined
: ['classes'] } )
Â
return (
<div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> <ul(property) JSX.IntrinsicElements.ul: JSX.HTMLAttributes<HTMLUListElement>
> <Forcreates a list elements from a list
it receives a map function as its child that receives a list element and an accessor with the index and returns a JSX-Element; if the list is empty, an optional fallback is returned:
```typescript
<For each={items} fallback={<div>No items</div>}>
{(item, index) => <div data-index={index()}>{item}</div>}
</For>
```
If you have a list with fixed indices and changing values, consider using `<Index>` instead.
(alias) function For<T, U extends JSX.Element>(props: {
each: readonly T[] | undefined | null | false;
fallback?: JSX.Element;
children: (item: T, index: Accessor<number>) => U;
}): Accessor<U[]>
import For
each(property) each: false | readonly {
name: string;
}[] | null | undefined
={classesconst classes: () => {
name: string;
}[] | undefined
()}> {course(parameter) course: {
name: string;
}
=> <li(property) JSX.IntrinsicElements.li: JSX.LiHTMLAttributes<HTMLLIElement>
>{course(parameter) course: {
name: string;
}
.name}</li(property) JSX.IntrinsicElements.li: JSX.LiHTMLAttributes<HTMLLIElement>
>} </Forcreates a list elements from a list
it receives a map function as its child that receives a list element and an accessor with the index and returns a JSX-Element; if the list is empty, an optional fallback is returned:
```typescript
<For each={items} fallback={<div>No items</div>}>
{(item, index) => <div data-index={index()}>{item}</div>}
</For>
```
If you have a list with fixed indices and changing values, consider using `<Index>` instead.
(alias) function For<T, U extends JSX.Element>(props: {
each: readonly T[] | undefined | null | false;
fallback?: JSX.Element;
children: (item: T, index: Accessor<number>) => U;
}): Accessor<U[]>
import For
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when(property) when: boolean | null | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
}> <li(property) JSX.IntrinsicElements.li: JSX.LiHTMLAttributes<HTMLLIElement>
>{enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.input(property) input?: string | undefined
}</li(property) JSX.IntrinsicElements.li: JSX.LiHTMLAttributes<HTMLLIElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> </ul(property) JSX.IntrinsicElements.ul: JSX.HTMLAttributes<HTMLUListElement>
> <button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
onClick(property) JSX.DOMAttributes<HTMLButtonElement>.onClick?: JSX.EventHandlerUnion<HTMLButtonElement, MouseEvent> | undefined
={() => enrollconst enroll: (vars: string) => Promise<void>
('Defense against the Dark Arts')} disabled(property) JSX.ButtonHTMLAttributes<HTMLButtonElement>.disabled?: boolean | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
} >
Enroll
</button(property) JSX.IntrinsicElements.button: JSX.ButtonHTMLAttributes<HTMLButtonElement>
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when(property) when: boolean | null | undefined
={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.pending(property) pending: boolean
}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>Enrolling...</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> <ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
when={enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.error}> <div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
>{enrollingconst enrolling: {
pending: boolean;
input?: string | undefined;
result?: void | undefined;
error?: any;
clear: () => void;
retry: () => void;
}
.error.message}</div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> </ShowConditionally render its children or an optional fallback component
(alias) function Show<T>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: JSX.Element;
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
}): () => JSX.Element (+1 overload)
import Show
> </div(property) JSX.IntrinsicElements.div: JSX.HTMLAttributes<HTMLDivElement>
> )
}
Reference
createRouteAction(action, options)
createRouteAction
is a hook that returns a tuple of two values: The first item in the tuple is the read side of the action. It a reactive object maintaining the state of the submissions of the action. The second item in the tuple is a function used to dispatch the action.
The second item also has another property called Form
which is a progressively enhanced version of the form
element. It is a component that can be used to submit the action.
Returns
[acting, act]