Skip to content

Commit

Permalink
docs: migrate Codesandbox embed for next.js swc example to Stackblitz (
Browse files Browse the repository at this point in the history
…#2773)

* docs: migrate Codesandbox embed for next.js swc example to Stackblitz

* docs: moved all code samples to stackblitz except 2

* fix: prettier
  • Loading branch information
niklasbec authored Oct 19, 2024
1 parent 8147e7b commit 00f5e27
Show file tree
Hide file tree
Showing 33 changed files with 59 additions and 57 deletions.
4 changes: 2 additions & 2 deletions docs/core/atom.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ It's a special function to invoke the write function of the self atom.

⚠️ It's provided primarily for internal usage and third-party library authors. Read the source code carefully to understand the behavior. Check release notes for any breaking/non-breaking changes.

## codesandbox
## Stackblitz

<CodeSandbox id="hg665r" />
<Stackblitz id="vitejs-vite-ccqxix" file="src%2FApp.tsx" />

```tsx
import { Suspense } from 'react'
Expand Down
4 changes: 2 additions & 2 deletions docs/extensions/cache.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ const App = () => {
}
```

### Codesandbox
### Stackblitz

<CodeSandbox id="h09znd" />
<Stackblitz id="vitejs-vite-p86ajq" file="src%2FApp.tsx" />
2 changes: 1 addition & 1 deletion docs/extensions/effect.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function MyComponent() {
}
```

<CodeSandbox id="tg9xsf" />
<Stackblitz id="vitejs-vite-fj5zjp" file="src%2FApp.tsx" />

### The `atomEffect` behavior

Expand Down
8 changes: 4 additions & 4 deletions docs/extensions/immer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Controls = () => {

Check this example with atomWithImmer:

<CodeSandbox id="83l6sr" />
<Stackblitz id="vitejs-vite-tblppw" file="src%2FApp.tsx" />

## withImmer

Expand Down Expand Up @@ -77,7 +77,7 @@ const Controls = () => {

Check this example with withImmer:

<CodeSandbox id="fn49h2" />
<Stackblitz id="vitejs-vite-jwfjqm" file="src%2FApp.tsx" />

## useImmerAtom

Expand Down Expand Up @@ -113,8 +113,8 @@ You can use `useSetImmerAtom` if you need only the setter part of `useImmerAtom`

Check this example with useImmerAtom:

<CodeSandbox id="np7y97" />
<Stackblitz id="vitejs-vite-k2rixl" file="src%2FApp.tsx" />

## Demo

<CodeSandbox id="9q4dg7" />
<Stackblitz id="vitejs-vite-tksbwq" file="src%2FApp.tsx" />
8 changes: 4 additions & 4 deletions docs/extensions/location.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ const App = () => {
}
```
### Codesandbox
### Stackblitz
<CodeSandbox id="kism55" />
<Stackblitz id="vitejs-vite-9v72fq" file="src%2FApp.tsx" />
## atomWithHash
Expand Down Expand Up @@ -157,9 +157,9 @@ const Counter = () => {
}
```
### Codesandbox
### Stackblitz
<CodeSandbox id="2mocd1" />
<Stackblitz id="vitejs-vite-zngpjt" file="src%2FApp.tsx" />
### Deleting Item
Expand Down
4 changes: 2 additions & 2 deletions docs/extensions/optics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ const Controls = () => {
}
```

#### Codesandbox
#### Stackblitz

<CodeSandbox id="nsy4u8" />
<Stackblitz id="vitejs-vite-jjunki" file="src%2FApp.tsx" />
6 changes: 3 additions & 3 deletions docs/extensions/query.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,12 @@ Similar to `atomsWithQuery` and `atomsWithInfiniteQuery`, `atomWithMutation` als

#### Basic demo

<CodeSandbox id="jm8mf7" />
<Stackblitz id="vitejs-vite-pr9eaf" file="src%2FApp.tsx" />

#### Devtools demo

<CodeSandbox id="zlp3pj" />
<Stackblitz id="vitejs-vite-btdqkh" file="src%2FApp.tsx" />

#### Hackernews

<CodeSandbox id="8v4mc4" />
<Stackblitz id="vitejs-vite-wqsyj8" file="src%2FApp.tsx" />
2 changes: 1 addition & 1 deletion docs/extensions/redux.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ const Counter = () => {

### Examples

<CodeSandbox id="487792" />
<Stackblitz id="vitejs-vite-qqsnwc" file="src%2FApp.tsx" />
2 changes: 1 addition & 1 deletion docs/extensions/relay.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const App = () => {

#### Examples

<CodeSandbox id="cxc6p5" />
<Stackblitz id="vitejs-vite-divyhe" file="src%2FApp.tsx" />

### atomWithMutation

Expand Down
4 changes: 2 additions & 2 deletions docs/extensions/scope.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const App = () => {
}
```

<CodeSandbox id="rf3r4n" />
<Stackblitz id="vitejs-vite-ctcuhj" file="src%2FApp.tsx" />

## `createIsolation`

Expand Down Expand Up @@ -149,4 +149,4 @@ const App = () => (
)
```

<CodeSandbox id="6dvlzf" />
<Stackblitz id="vitejs-vite-8akpt6" file="src%2FApp.tsx" />
2 changes: 1 addition & 1 deletion docs/extensions/trpc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const Pokemon = () => {

#### Examples

<CodeSandbox id="j1vhcg" />
<Stackblitz id="vitejs-vite-8kgfpj" file="src%2FApp.tsx" />

### atomWithMutation

Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/urql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function use(promise: Promise<any> | any) {

#### Basic demo

<CodeSandbox id="5rwunq" />
<Stackblitz id="vitejs-vite-1nhtrj" file="src%2FApp.tsx" />

### Referencing the same instance of the client for both atoms and urql provider

Expand Down
4 changes: 2 additions & 2 deletions docs/extensions/valtio.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ atomWithProxy(proxyObject, { sync: true })

### Examples

<CodeSandbox id="ew98ll" />
<Stackblitz id="vitejs-vite-wmsazx" file="src%2FApp.tsx" />

## mutableAtom

Expand Down Expand Up @@ -102,7 +102,7 @@ mutableAtom(value, options?)
### Examples
<CodeSandbox id="f84sk5" />
<Stackblitz id="vitejs-vite-wmsazx" file="src%2FApp.tsx" />
### Caution on Mutating Proxies
Expand Down
4 changes: 2 additions & 2 deletions docs/extensions/xstate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ const YourComponent = () => {

Check examples with atomWithMachine:

<CodeSandbox id="fxtoe3" />
<Stackblitz id="vitejs-vite-oqfhy4" file="src%2FApp.tsx" />

Restartable machine:

<CodeSandbox id="n179xd" />
<Stackblitz id="vitejs-vite-tqdtym" file="src%2FApp.tsx" />

### Tutorials

Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/zustand.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ const Counter = () => {

### Examples

<CodeSandbox id="mqtugt" />
<Stackblitz id="vitejs-vite-kfzyun" file="src%2FApp.tsx" />
4 changes: 2 additions & 2 deletions docs/guides/persistence.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const Persist = () => {
#### Examples
<CodeSandbox id="g96xjx" />
<Stackblitz id="vitejs-vite-zda5uw" file="src%2FApp.tsx" />
### A pattern with atomFamily
Expand Down Expand Up @@ -201,4 +201,4 @@ const Persist = () => {
#### Examples
<CodeSandbox id="oyiw5r" />
<Stackblitz id="vitejs-vite-z4kjv3" file="src%2FApp.tsx" />
4 changes: 2 additions & 2 deletions docs/guides/resettable.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const TodoList = () => {

### Examples

<CodeSandbox id="w91cq" />
<Stackblitz id="vitejs-vite-2s1vg6" file="src%2FApp.tsx" />

### Derived atom with RESET symbol

Expand Down Expand Up @@ -84,4 +84,4 @@ const ResetExample = () => {

### Examples

<CodeSandbox id="41c0s" />
<Stackblitz id="vitejs-vite-wjgquh" file="src%2FApp.tsx" />
2 changes: 1 addition & 1 deletion docs/guides/using-store-outside-react.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ export default function App() {

### Examples

<CodeSandbox id="2jvynm" />
<Stackblitz id="vitejs-vite-m1h61f" file="src%2FApp.tsx" />
2 changes: 1 addition & 1 deletion docs/recipes/atom-with-broadcast.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ const ListOfThings = () => {
}
```

<CodeSandbox id="ugkzm0" />
<Stackblitz id="vitejs-vite-imqbzg" file="src%2FApp.tsx" />
2 changes: 1 addition & 1 deletion docs/recipes/atom-with-debounce.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ When typing a pokemon's name in `<SearchInput>`, we do not send a get request on

This reduces the number of backend requests to the server.

<CodeSandbox id="cjrz2y" />
<Stackblitz id="vitejs-vite-chvvtu" file="src%2FApp.tsx" />
2 changes: 1 addition & 1 deletion docs/recipes/atom-with-refresh-and-default.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ const resetRootAtom = atom(null, (get, set) => {
})
```

<CodeSandbox id="tcx2mk" />
<Stackblitz id="vitejs-vite-1m7ce3" file="src%2FApp.tsx" />
4 changes: 2 additions & 2 deletions docs/recipes/custom-useatom-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ useFocusAtom(anAtom) {
}
```

#### CodeSandbox
#### Stackblitz

<CodeSandbox id="y5wef8" />
<Stackblitz id="vitejs-vite-ge1mah" file="src%2FApp.tsx" />

Please note that in this case `keyFn` must be stable, either define outside render or wrap with `useCallback`.
2 changes: 1 addition & 1 deletion docs/recipes/use-reducer-atom.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ const Counter = () => {
}
```

<CodeSandbox id="eg0mw" />
<Stackblitz id="vitejs-vite-gsctj6" file="src%2FApp.tsx" />
6 changes: 3 additions & 3 deletions docs/tools/devtools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const App = () => {

### Preview

<CodeSandbox id="k5p12d" />
<Stackblitz id="vitejs-vite-hzldhk" file="src%2FApp.tsx" />

## useAtomsDebugValue

Expand Down Expand Up @@ -207,7 +207,7 @@ const App = () => (
)
```

<CodeSandbox id="vvp12f" />
<Stackblitz id="vitejs-vite-dmts5e" file="src%2FApp.tsx" />

## useAtomDevtools

Expand Down Expand Up @@ -305,7 +305,7 @@ export default function App() {
}
```

<CodeSandbox id="3xobn" />
<Stackblitz id="vitejs-vite-lpr5rs" file="src%2FApp.tsx" />

## useAtomsSnapshot

Expand Down
2 changes: 1 addition & 1 deletion docs/tools/swc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ module.exports = {

### Next.js

<CodeSandbox id="ygiuzm" />
<Stackblitz id="stackblitz-starters-ha5txx" file="app%2Fpage.tsx" />
4 changes: 2 additions & 2 deletions docs/utilities/async.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ const counterAtom2 = atomWithObservable(() => counterSubject, {
})
```

### Codesandbox
### Stackblitz

<CodeSandbox id="88pnt" />
<Stackblitz id="vitejs-vite-3bkqrb" file="src%2FApp.tsx" />

## unwrap

Expand Down
4 changes: 2 additions & 2 deletions docs/utilities/callback.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ const Monitor = () => {
}
```
### Codesandbox
### Stackblitz
<CodeSandbox id="95gxnt" />
<Stackblitz id="vitejs-vite-ekxjhs" file="src%2FApp.tsx" />
4 changes: 2 additions & 2 deletions docs/utilities/family.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ const todoFamily = atomFamily(
)
```

### Codesandbox
### Stackblitz

<CodeSandbox id="huxd4i" />
<Stackblitz id="vitejs-vite-rx6npn" file="src%2FApp.tsx" />
4 changes: 3 additions & 1 deletion docs/utilities/reducer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const countReducer = (prev, action) => {
const countReducerAtom = atomWithReducer(0, countReducer)
```

<CodeSandbox id="g3tsx" />
### Stackblitz

<Stackblitz id="vitejs-vite-bbpmjn" file="src%2FApp.tsx" />

## useReducerAtom

Expand Down
4 changes: 2 additions & 2 deletions docs/utilities/resettable.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ const count1Atom = atom(1)
const count2Atom = atomWithDefault((get) => get(count1Atom) * 2)
```

### Codesandbox
### Stackblitz

<CodeSandbox id="unfro" />
<Stackblitz id="vitejs-vite-gffb5v" file="src%2FApp.tsx" />

### Resetting default values

Expand Down
4 changes: 2 additions & 2 deletions docs/utilities/select.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ const Component = () => {
}
```

### CodeSandbox
### Stackblitz

<CodeSandbox id="8czek" />
<Stackblitz id="vitejs-vite-tgejq7" file="src%2FApp.tsx" />
2 changes: 1 addition & 1 deletion docs/utilities/split.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Important considerations for the `keyExtractor`:

Here's an example demonstrating the use of `splitAtom`:

<CodeSandbox id="s4hvgo" />
<Stackblitz id="vitejs-vite-oavdw2" file="src%2FApp.tsx" />

```tsx
import { Provider, atom, useAtom, PrimitiveAtom } from 'jotai'
Expand Down
2 changes: 1 addition & 1 deletion docs/utilities/storage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The `atomWithStorage` function creates an atom with a value persisted in `localS

If not specified, the default storage implementation uses `localStorage` for storage/retrieval, `JSON.stringify()`/`JSON.parse()` for serialization/deserialization, and subscribes to `storage` events for cross-tab synchronization.

<CodeSandbox id="vuwi7" />
<Stackblitz id="vitejs-vite-wewrmi" file="src%2FApp.tsx" />

### `createJSONStorage` util

Expand Down

0 comments on commit 00f5e27

Please sign in to comment.