Skip to content

Commit

Permalink
examples: use atomWithInitialValue
Browse files Browse the repository at this point in the history
  • Loading branch information
koichik committed Jul 15, 2022
1 parent 4b76530 commit e2cb2f0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/history-sync-json/src/components/Textfield/index.tsx
@@ -1,17 +1,17 @@
import { string } from '@recoiljs/refine'
import { atom, useRecoilState } from 'recoil'
import { useRecoilState } from 'recoil'
import { syncEffect } from 'recoil-sync'
import { atomWithInitialValue } from 'recoil-sync-next'

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

export const textState = atom<string>({
export const textState = atomWithInitialValue<string>({
key: 'textState',
default: '',
effects: [syncEffect({ refine: string() })],
})

export const Textfield: React.FC = () => {
const [text, setText] = useRecoilState(textState)
const [text, setText] = useRecoilState(textState('Recoil'))

return (
<div className={styles.wrapper}>
Expand Down

0 comments on commit e2cb2f0

Please sign in to comment.