Skip to content

Commit

Permalink
examples: use initializableAtom(Family)
Browse files Browse the repository at this point in the history
  • Loading branch information
koichik committed Aug 2, 2022
1 parent 2d14b85 commit b07ca37
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/history-sync-json/src/components/Counter/index.tsx
@@ -1,11 +1,11 @@
import { number } from '@recoiljs/refine'
import { useRecoilState } from 'recoil'
import { syncEffect } from 'recoil-sync'
import { atomFamilyWithInitialValue } from 'recoil-sync-next'
import { initializableAtomFamily } from 'recoil-sync-next'

import styles from './index.module.css'

export const counter = atomFamilyWithInitialValue<number, string>({
export const counter = initializableAtomFamily<number, string>({
key: 'counterState',
effects: [syncEffect({ refine: number() })],
})
Expand Down
4 changes: 2 additions & 2 deletions examples/history-sync-json/src/components/Textfield/index.tsx
@@ -1,11 +1,11 @@
import { string } from '@recoiljs/refine'
import { useRecoilState } from 'recoil'
import { syncEffect } from 'recoil-sync'
import { atomWithInitialValue } from 'recoil-sync-next'
import { initializableAtom } from 'recoil-sync-next'

import styles from './index.module.css'

export const textState = atomWithInitialValue<string>({
export const textState = initializableAtom<string>({
key: 'textState',
effects: [syncEffect({ refine: string() })],
})
Expand Down
4 changes: 2 additions & 2 deletions examples/url-sync-json/src/components/Counter/index.tsx
@@ -1,11 +1,11 @@
import { number } from '@recoiljs/refine'
import { useRecoilState } from 'recoil'
import { syncEffect } from 'recoil-sync'
import { atomFamilyWithInitialValue } from 'recoil-sync-next'
import { initializableAtomFamily } from 'recoil-sync-next'

import styles from './index.module.css'

export const counter = atomFamilyWithInitialValue<number, string>({
export const counter = initializableAtomFamily<number, string>({
key: 'counterState',
effects: [syncEffect({ storeKey: 'url-json-store', refine: number() })],
})
Expand Down
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -37,10 +37,13 @@
"lint-fix:ex": "run-s -c lint-fix:ex:*",
"lint-fix:ex:eslint": "CMD=lint-fix:eslint run-s -c run-ex:*",
"lint-fix:ex:prettier": "CMD=lint-fix:prettier run-s -c run-ex:*",
"local-copy": "CMD=local-copy run-s -c run-ex:*",
"test": "jest",
"prepare": "simple-git-hooks",
"run-ex:history-sync-json": "yarn --cwd examples/history-sync-json run $CMD",
"run-ex:url-sync-json": "yarn --cwd examples/url-sync-json run $CMD"
"run-ex:history-sync-transit": "yarn --cwd examples/history-sync-transit run $CMD",
"run-ex:url-sync-json": "yarn --cwd examples/url-sync-json run $CMD",
"run-ex:url-sync-transit": "yarn --cwd examples/url-sync-transit run $CMD"
},
"simple-git-hooks": {
"pre-commit": "yarn run lint:lib:eslint && yarn run lint:ex:eslint && yarn run test"
Expand Down

0 comments on commit b07ca37

Please sign in to comment.