
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@r/redux-state-archiver
Advanced tools
A collection of React components for serializing your redux state
makeStateArchiver returns a React Component to be used in a subtree of from react-redux. It will listen to your redux state and archive that data when it changes.
The arguments to makeStateArchiver are simliar to createSelector, pass in an array of selectors that extract the data you from state you wish to serialize.
const themeSelector = (state) => state.theme;
After your selectors, pass in a 'combiner' to merge the data from your selectors into an object that will represent the overall state of data you wish to serialize;
const combiner = (theme) => ({ theme });
Finally pass in a state archiver, a function that takes an object, and persists it
in some manner. You probably will never pass this, as most apps can use the helper functions
makeCookieArchiver or makeLocalStorageArchiver. These functions try to match the signature
of connect from 'react-redux', so you pass your selectors as arguments without wrapping them
in an array.
Note: Your archiver should be able to deal with persisting the diff of what's output from your combiner.
Full example:
import React from 'react';
import { Provider } from 'react-redux';
import { makeCookieArchiver } from '@r/redux-state-archiver';
import { UrlSync } from '@r/platform/components';
import App from './src/App';
const themeSelector = (state) => state.theme;
const compactSelector = (state) => state.compact;
const combiner = (theme, compact) => ({ theme, compact });
const CookieSync = makeCookieArchiver(
themeSelector,
compactSelector,
combiner,
);
const renderApp = (store) => (
<Provider store={ store }>
<App />
<UrlSync />
<CookieSync />
</Provider>
);
FAQs
A collection of React components for serializing your redux state
The npm package @r/redux-state-archiver receives a total of 1 weekly downloads. As such, @r/redux-state-archiver popularity was classified as not popular.
We found that @r/redux-state-archiver demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.