Comments (6)
I was able to by setting both getItem
and setItem
:
setStorageType({
setItem: () => {},
getItem: () => {
return createInitState();
},
...localStorage
});
createStore({ ...createInitState() });
from little-state-machine.
hey @devoNOTbevo thanks for the support :) keep it simple. Maybe we should create a folder for examples and doing it just like RHF (code + CSB)? your thoughts?
from little-state-machine.
@bluebill1049 yes, I think that could be helpful. I liked that about RHF actually - great job on that site.
One question - is it possible to prevent LSM from storing at all? This is developer's responsibility, but I am concerned about instances where user has not given consent to storage, when it's necessary.
In my example, LSM is still storing the data, I'm just not using all of it.
from little-state-machine.
oh you probably can use setStorageType
and give it an object with session storage alike API.
call setStorageType({ setItme: () => {}, ...})
before createStore
basically save data into an object in memory instead of session/local stroage.
from little-state-machine.
@bluebill1049 I will give that a try on a current project and report back. These might can be examples to give also, like you suggested.
from little-state-machine.
if i have some extra time, i will do a codesandbox for you @devoNOTbevo :)
from little-state-machine.
Related Issues (20)
- When Cookies are disabled, actions.updateAction({ name: 'bill' })} throws an error- TypeError: o.storageType.setItem is not a function. The website handles Cookie Disabled error gracefully by throwing a message, but this breaks the App. How can we avoid that? HOT 1
- Does `useStateMachine` trigger re-renders when an update occurs in another component tree? HOT 5
- unable to create mock provider for Jest+React testing Lib HOT 6
- unable to clear store HOT 3
- Help with the LocalStorage and Next.JS HOT 1
- Bf a /:/66 HOT 1
- npm ERR! code ERESOLVE HOT 1
- How to push data to an array state machine HOT 2
- Code Sample in TS is not working correctly HOT 4
- Reset store to initial value ? HOT 1
- Catching Storage error HOT 1
- Error when using with next.js HOT 1
- state not up to date HOT 3
- how to get the global state value outside of the component. HOT 1
- Setting up testing patterns for LSM (React Testing Lib + Jest) - LSM returns empty object in JSDOM HOT 1
- Access the CreateStore Outside a React Component HOT 1
- Dynamically set store name with data from backend HOT 1
- Changing schema of state - guidance on versioning/migrations?
- Type Error for actions without a payload.
- List of Contributors to be present in the Readme HOT 2
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 little-state-machine.