Comments (3)
it would be nice to have it as a global config so it always waits for it to be synced and then returns the initial value first, something like:
export const useSettingsStore = createChromeStorageStateHookLocal(SETTINGS_KEY, INITIAL_VALUE, { waitForInitialToBeResolved: true });
from use-chrome-storage.
Hi @Othmanosx
Take a look at the documentation. At Initial value flow.
Hook returns boolean isInitialStateResolved
which will be set to true
once synchronized with chrome.storage
.
const [{ isDark }, setValue, isPersistent, error, isInitialStateResolved] = useSettingsStore()
{isInitialStateResolved && <div>isDark: {isDark}</div>}
from use-chrome-storage.
Hi @Othmanosx
It sounds like a good idea! PR is welcome!
from use-chrome-storage.
Related Issues (17)
- I am facing this issue while using this library HOT 5
- is setState necessary in the updateValue Callback? HOT 1
- Doesn't work for background scripts HOT 1
- Add proper typing support for typescript HOT 1
- Add session storage support
- Create Chrome Storage State Hook Local/Sync wrong type?
- Update Types HOT 2
- Typescript error - must have a '[Symbol.iterator]()' method that returns an iterator. HOT 2
- `createChromeStorageStateHookLocal` knowing when value has been fetched (or none found in storage) HOT 15
- Review and improve typing - index.d.ts
- Uncaught TypeError when running localhost HOT 3
- createChromeStorageStateHookSession actually storing in 'sync' HOT 1
- value in useEffect is undefined HOT 7
- Stored objects and arrays retrieved as string HOT 2
- chrome.storage.local.get doesn't return the initial values HOT 1
- Add LICENSE file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from use-chrome-storage.