Skip to content

Commit

Permalink
Merge branch 'main' into feat/starter-example
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi authored Dec 22, 2024
2 parents 7fb9ebe + 36062fb commit b89df35
Show file tree
Hide file tree
Showing 84 changed files with 6,765 additions and 4,709 deletions.
1 change: 0 additions & 1 deletion .github/workflows/compressed-size-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
with:
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- uses: preactjs/compressed-size-action@v2
with:
pattern: './dist/**/*.{js,mjs}'
2 changes: 1 addition & 1 deletion .github/workflows/cr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 20
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ecosystem-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ jobs:
with:
node-version: 22
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
- run: pnpm install
- name: Get Short SHA
id: short_sha
run: |
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/lint-and-type.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
with:
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
- run: pnpm install
- run: pnpm test:format
- run: pnpm test:types
- run: pnpm test:lint
3 changes: 1 addition & 2 deletions .github/workflows/livecodes-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ jobs:
with:
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- uses: live-codes/preview-in-livecodes@v1
with:
install-command: pnpm install --frozen-lockfile
install-command: pnpm install
build-command: pnpm build
base-url: 'https://{{LC::REF}}.preview-in-livecodes-demo.pages.dev'
3 changes: 1 addition & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ jobs:
node-version: 20
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
- run: pnpm install
- run: pnpm test
- run: pnpm build
- run: npm publish
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/test-multiple-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ jobs:
with:
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
- run: pnpm install
- run: pnpm build
- name: Use React 17 for production test
if: ${{ matrix.env == 'production' }}
run: |
pnpm json -I -f package.json -e "this.pnpm.patchedDependencies={};"
pnpm add -D [email protected] [email protected] @testing-library/[email protected]
- name: Patch for DEV-ONLY
if: ${{ matrix.env == 'development' }}
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/test-multiple-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
with:
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
- run: pnpm install
- run: pnpm build # we don't have any other workflows to test build
- run: pnpm test:spec

Expand All @@ -43,12 +42,10 @@ jobs:
with:
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
- run: pnpm install
- name: Install legacy testing-library
if: ${{ startsWith(matrix.react, '16.') || startsWith(matrix.react, '17.') }}
run: |
pnpm json -I -f package.json -e "this.pnpm.patchedDependencies={};"
pnpm add -D @testing-library/[email protected]
- name: Patch for React 16
if: ${{ startsWith(matrix.react, '16.') }}
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/test-old-typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ jobs:
with:
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
- run: pnpm install
- run: pnpm build
- name: Patch for all TS
run: |
Expand Down Expand Up @@ -91,7 +90,6 @@ jobs:
- name: Patch testing setup for older TS
if: ${{ matrix.typescript == '4.0.5' || startsWith(matrix.typescript, '3.') }}
run: |
pnpm json -I -f package.json -e "this.pnpm.patchedDependencies={};"
pnpm add -D @testing-library/[email protected] @testing-library/[email protected] @types/[email protected]
rm node_modules/vitest/dist/*.d.ts
echo "declare module 'vitest'" >> ./src/types.d.ts
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/cache.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ a third-party library to help such use cases.
### Install

```
npm i jotai-cache
npm install jotai-cache
```

## atomWithCache
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/effect.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords: effect, atom effect, side effect, side-effect, sideeffect
## install

```
npm i jotai-effect
npm install jotai-effect
```

## atomEffect
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/immer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords: immer
You have to install `immer` and `jotai-immer` to use this feature.

```
npm i immer jotai-immer
npm install immer jotai-immer
```

## atomWithImmer
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/location.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To deal with `window.location`, we have some functions to create atoms.
You have to install `jotai-location` to use this feature.

```
npm i jotai-location
npm install jotai-location
```

## atomWithLocation
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/optics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords: optics
You have to install `optics-ts` and `jotai-optics` to use this feature.

```
npm i optics-ts jotai-optics
npm install optics-ts jotai-optics
```

## focusAtom
Expand Down
6 changes: 4 additions & 2 deletions docs/extensions/query.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jotai-tanstack-query currently supports TanStack Query v5.
In addition to `jotai`, you have to install `jotai-tanstack-query` and `@tanstack/query-core` to use the extension.

```bash
npm i jotai-tanstack-query @tanstack/query-core
npm install jotai-tanstack-query @tanstack/query-core
```

### Incremental Adoption
Expand Down Expand Up @@ -263,6 +263,8 @@ Although they reference methods same query key (`'todos'`), the `onSuccess` inva

This will result in `todosAtom` showing stale data as it was not prompted to refetch.

⚠️ Note: When using **Typescript**, it is recommended to use a Map when passing the queryClient value to useHydrateAtoms. You can find a working example in the [Initializing State on Render docs](https://jotai.org/docs/guides/initialize-atom-on-render#using-typescript)

```jsx
import { Provider } from 'jotai/react'
import { useHydrateAtoms } from 'jotai/react/utils'
Expand Down Expand Up @@ -338,7 +340,7 @@ See [a working example](https://codesandbox.io/s/4gfp6z) to learn more.
In order to use the Devtools, you need to install it additionally.

```bash
npm i @tanstack/react-query-devtools
npm install @tanstack/react-query-devtools
```

All you have to do is put the `<ReactQueryDevtools />` within `<QueryClientProvider />`.
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/redux.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ and sync with atoms in Jotai.
You have to install `redux` and `jotai-redux` to use this feature.

```
npm i redux jotai-redux
npm install redux jotai-redux
```

## atomWithStore
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/relay.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You can use Jotai with [Relay](https://relay.dev).
You have to install `jotai-relay` and `relay-runtime`.

```
npm i jotai-relay relay-runtime
npm install jotai-relay relay-runtime
```

### Usage
Expand Down
4 changes: 2 additions & 2 deletions docs/extensions/scope.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ and the use of those atoms is scoped within the subtree.
### Install

```
npm i jotai-scope
npm install jotai-scope
```

### Counter Example
Expand Down Expand Up @@ -105,7 +105,7 @@ See [Motivation](https://github.com/saasquatch/bunshi/tree/v1.1.1#motivation) fo
### Install

```
npm i bunshi
npm install bunshi
```

### Counter Example
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/trpc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ You can use Jotai with [tRPC](https://trpc.io).
You have to install `jotai-trpc`, `@trpc/client` and `@trpc/server` to use the extension.

```
npm i jotai-trpc @trpc/client @trpc/server
npm install jotai-trpc @trpc/client @trpc/server
```

### Usage
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/urql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ From the [Overview docs](https://formidable.com/open-source/urql/docs/):
You have to install `jotai-urql`, `@urql/core` and `wonka` to use the extension.

```
npm i jotai-urql @urql/core wonka
npm install jotai-urql @urql/core wonka
```

### Exported functions
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/valtio.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This only uses the vanilla api of valtio.
You have to install `valtio` and `jotai-valtio` to use this feature.

```
npm i valtio jotai-valtio
npm install valtio jotai-valtio
```

## atomWithProxy
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/xstate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ a better and safer abstraction for state management.
You have to install `xstate` and `jotai-xstate` to use this feature.

```
npm i xstate jotai-xstate
npm install xstate jotai-xstate
```

## atomWithMachine
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/zustand.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This only uses the vanilla api of zustand.
You have to install `zustand` and `jotai-zustand` to use this feature.

```
npm i zustand jotai-zustand
npm install zustand jotai-zustand
```

## atomWithStore
Expand Down
2 changes: 1 addition & 1 deletion docs/third-party/derive.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Building data graphs with these dual-natured (sometimes async, sometimes sync) a
You have to install `jotai-derive` to use this feature.

```
npm i jotai-derive
npm install jotai-derive
```

## derive
Expand Down
2 changes: 1 addition & 1 deletion docs/third-party/history.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords: history,undo,redo,jotai
## install

```
npm i jotai-history
npm install jotai-history
```

## withHistory
Expand Down
2 changes: 1 addition & 1 deletion docs/tools/devtools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords: devtools,debug,snapshot
Install `jotai-devtools` to your project to get started.

```sh
npm i jotai-devtools
npm install jotai-devtools
```

### Notes
Expand Down
2 changes: 2 additions & 0 deletions docs/utilities/ssr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ useHydrateAtoms([
] as const)
```

Or you may need to use a Map when passing the atom value to useHydrateAtoms. You can find a working example in the [Initializing State on Render docs](https://jotai.org/docs/guides/initialize-atom-on-render#using-typescript).

### Demo

<Stackblitz id="stackblitz-starters-b7cvxi" file="pages%2Findex.tsx" />
Expand Down
12 changes: 6 additions & 6 deletions examples/hacker_news/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Hacker News [![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?style=flat-square&logo=codesandbox)](https://githubbox.com/pmndrs/jotai/tree/main/examples/hacker_news)
# Hacker News [![Open in StackBlitz](https://img.shields.io/badge/Open%20in-StackBlitz-blue?style=flat-square&logo=stackblitz)](https://stackblitz.com/github/pmndrs/jotai/tree/main/examples/hacker_news)

## Description

Expand All @@ -10,15 +10,15 @@ Demonstrate a news articles with jotai, hit next to see more articles.
git clone https://github.com/pmndrs/jotai

# install project dependencies & build the library
cd jotai && yarn
cd jotai && pnpm install

# move to the examples folder & install dependencies
cd examples/hacker_news && yarn
cd examples/hacker_news && pnpm install

# start the dev server
yarn start
pnpm dev
```

## Set up on codesandbox
## Set up on `StackBlitz`

Link: https://githubbox.com/pmndrs/jotai/tree/main/examples/hacker_news
Link: https://stackblitz.com/github/pmndrs/jotai/tree/main/examples/hacker_news
6 changes: 3 additions & 3 deletions examples/hacker_news/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"dependencies": {
"@react-spring/web": "^9.2.3",
"html-react-parser": "^1.2.6",
"jotai": "^2.0.4",
"jotai": "^2.10.4",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
"@vitejs/plugin-react": "^4.0.0",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.0.0",
"vite": "^4.0.0"
"vite": "^6.0.5"
}
}
Loading

0 comments on commit b89df35

Please sign in to comment.