Set State

Arbitrary way to persist some state into store.

import { getState, setState } from '@rebased/state';
console.log(getState());
// { _fetch: {} }
setState('hello', { world: 2021 });
console.log(getState());
// { _fetch: { hello: { world: 2021 } } }
caution

Use with caution, the most organized and scalable way to modify state is dispatching actions through custom reducers.

Disable cache#

By default Rebased detects if you're using the cache package and will also auto save data into storage.

import { setState } from '@rebased/state';
setState('numbers', [1, 2, 3], { save: false }); // skip cache