www: cleanup miscellaneous doc items (#1419)
This commit is contained in:
@@ -12,6 +12,7 @@ All of this content is lifted from this great
|
||||
Imagine we have `Counter.tsx` like this:
|
||||
|
||||
```ts
|
||||
// islands/Counter.tsx
|
||||
import { useSignal } from "@preact/signals";
|
||||
import { Button } from "../components/Button.tsx";
|
||||
|
||||
@@ -49,6 +50,7 @@ here, yet.
|
||||
But we can switch things up by looking at a `SynchronizedSlider.tsx` like this:
|
||||
|
||||
```ts
|
||||
// islands/SynchronizedSlider.tsx
|
||||
import { Signal } from "@preact/signals";
|
||||
|
||||
interface SliderProps {
|
||||
@@ -74,6 +76,7 @@ export default function SynchronizedSlider(props: SliderProps) {
|
||||
Now if we were to do the following...
|
||||
|
||||
```ts
|
||||
// routes/index.tsx
|
||||
export default function Home() {
|
||||
const sliderSignal = useSignal(50);
|
||||
return (
|
||||
@@ -93,17 +96,15 @@ they would all use the same value.
|
||||
We can also create a `signal` in a utility file and export it for consumption
|
||||
across multiple places.
|
||||
|
||||
`./utils/cart.ts`
|
||||
|
||||
```ts
|
||||
// utils/cart.ts
|
||||
import { signal } from "@preact/signals";
|
||||
|
||||
export const cart = signal<string[]>([]);
|
||||
```
|
||||
|
||||
`./islands/AddToCart.tsx`
|
||||
|
||||
```ts
|
||||
// islands/AddToCart.tsx
|
||||
import { Button } from "../components/Button.tsx";
|
||||
import { cart } from "../utils/cart.ts";
|
||||
|
||||
@@ -125,9 +126,8 @@ export default function AddToCart(props: AddToCartProps) {
|
||||
}
|
||||
```
|
||||
|
||||
`./islands/Cart.tsx`
|
||||
|
||||
```ts
|
||||
// islands/Cart.tsx
|
||||
import { Button } from "../components/Button.tsx";
|
||||
import { cart } from "../utils/cart.ts";
|
||||
import * as icons from "../components/Icons.tsx";
|
||||
|
||||
Reference in New Issue
Block a user