A simple state management library in react app. State sharing and persist never been so easy :)
MIT License
Published by suhaotian 6 months ago
Revert: 'use client'
Published by suhaotian 6 months ago
use client
to Provider.tsx
componentemitPersistReady
and onPersistReady
utilsFull Changelog: https://github.com/suhaotian/use-one/compare/v1.4.0...v1.4.1
Published by suhaotian 6 months ago
New features compare to v1.1.1:
persistStore
to persist your storeusePersist
to persist react hook's stateFull Changelog: https://github.com/suhaotian/use-one/compare/v1.1.1...v1.4.0
Published by suhaotian 6 months ago
isReady
always false after cleanFull Changelog: https://github.com/suhaotian/use-one/compare/v1.4.0-beta.3...v1.4.0-beta.4
Published by suhaotian 6 months ago
Full Changelog: https://github.com/suhaotian/use-one/compare/v1.4.0-beta.2...v1.4.0-beta.3
Published by suhaotian 6 months ago
eventemitter3
deps. Thanks @arkatsy ❤️ https://github.com/suhaotian/use-one/issues/3
Full Changelog: https://github.com/suhaotian/use-one/compare/v1.4.0-beta.1...v1.4.0-beta.2
Published by suhaotian 6 months ago
persistStore
wrong when cahce data is nullPublished by suhaotian 6 months ago
persistStore
support React Native / ExpoUsage:
import { create, persistStore, wrapState, isClient } from 'use-one';
const initialState = wrapState({ count: 0 }); // -> { ready: false, count: 0 }
const [use, store] = create(initialState);
console.log('isClient', isClient);
isClient && persistStore(store, { key: '@CACHE_KEY', debounce: 100 });
Published by suhaotian 6 months ago
transform: state => state
to persistStore
's optionsPublished by suhaotian 6 months ago
Published by suhaotian 6 months ago
**Feat: **
Usage:
import { create } from 'use-one';
import { persistStore, wrapState, isClient } from 'use-one/persist';
const initialState = wrapState({ count: 0 }); // -> { ready: false, count: 0 }
const [use, store] = create(initialState);
console.log('isClient', isClient);
isClient && persistStore(store, { key: '@CACHE_KEY', debounce: 100 });
Published by suhaotian 8 months ago
Use different entry with 'react-server': './index.js',
inspired from https://www.npmjs.com/package/server-only?activeTab=code
Published by suhaotian 10 months ago
Add keywords
in package.json
Published by suhaotian 11 months ago
.replaceState
to .setState
.replaceState
Published by suhaotian over 1 year ago
Breaking Change: createOne
rename to create
, and deprecated
createOne
Breaking Change: remove setState
please use replaceState
instead
remove tsdx and add bunchee
remove MAX_UPDATE_COUNT_NUMBER
clean types: syncState
and replaceState
support oldState => newState
export type createOptions
=> export type CreateOptions
add test, e2e tests, and npm auto release github actions
update deps and use pnpm
add changelog
Update README
Published by suhaotian almost 2 years ago
Now no more manual install eventemitter3
,
And remove tsdk
bundle replace with bunchee
.
Published by suhaotian about 3 years ago
fix esm module import error
Published by suhaotian almost 4 years ago
Published by suhaotian about 4 years ago
.syncState
method, this method just sync state without emit update, useful for list component update