question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Way to turn off storage by default

See original GitHub issue

I was using little-state-machine with react-hook-form and had some conditional state that I didn’t want lsm to remember on load.

The only way I found to implement this was something like this:

const initialState = {/* whatever you want */}
createStore(
  { ...initialState },
  {
    middleWares: [],
    syncStores: {
      // you can sync with external store and transform the data
      externalStoreName: 'initial',
      transform: ({ externalStoreData, currentStoreData }) => {
        return {
          ...initialState,
         // here add any other state from external or current
        };
      }
    }
  }
);

I actually really like this package a lot and would be happy submitting a PR for what I’m thinking, unless I’m not on the right track.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
devoNOTbevocommented, Apr 24, 2020

I was able to by setting both getItem and setItem:

setStorageType({
    setItem: () => {},
    getItem: () => {
        return createInitState();
    },
    ...localStorage
});
createStore({ ...createInitState() });
1reaction
bluebill1049commented, Apr 1, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to turn off Storage Sense in Windows 10 — Auslogics Blog
Method 1: How to Disable Storage Sense Using the Settings App ; Launch the “Settings” app using the Win + I shortcut. Launch...
Read more >
Manage drive space with Storage Sense - Microsoft Support
Go to Start > Settings > System > Storage . Select Storage Sense. Choose your desired settings, including when to run Storage Sense,...
Read more >
Free up space - Android Help - Google Support
Free up storage · Close apps that don't respond · Uninstall apps you don't use · Clear the app's cache & data ·...
Read more >
How to enable, disable, or clear your browser's "Web Storage ...
To enable or disable Web Storage in Internet Explorer: ... Select Extras → Internet Options → Advanced Tab → Go to Security →...
Read more >
How to Enable and Configure Storage Sense on Windows 11
Once you have Settings open, click System from the list on the left. Then, on the right, scroll down and click Storage. system...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found