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.

Setup for config in persistState

See original GitHub issue

Hi, I’m struggling to figure out how to select a subset of what config needs to look like with keys/values inside of persistState. There are code snippets but it’s a little difficult to piece them together and figure out what is needed to just select a subset of fields to sync to localStorage. Would you be able to elaborate more on how to accomplish this? My state currently looks like below.

{
  key1: {},
  key2: {
    innerKey1: [],
    innerKey2: [],
    innerKey3: null
  }
}

If I wanted to select innerKey1 here, how would I go about that?

// Pseudocode
compose(
  applyMiddleware(thunk),
  persistState('key2', /* config_to_access_innerKey1 */)
);

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
Petestacommented, Oct 27, 2016

Here’s how it needs to be done.

function customSlicer() {
  return (state) => {
    const { auth } = state;
    return { auth };
  }
}

compose(
  applyMiddleware(thunk),
  persistState(null, { slicer: myCustomSlicer() })
);
0reactions
cyberpolincommented, Dec 7, 2017

Any one is getting TypeError: Object(...) is not a function

Read more comments on GitHub >

github_iconTop Results From Across the Web

Persist state with Redux Persist using Redux Toolkit in React
Setting up React; Persisting state with Redux Persist; Nested persists using Redux Persist; Specify how the incoming state is merged ...
Read more >
Persist State | Elf | A Reactive Store with Magical Powers
The persistState() function gives you the ability to persist some of the app's state, by saving it to localStorage/sessionStorage or anything that implements ......
Read more >
Persist state - Guriddo jqGrid JS
The Guriddo jqGrid exposes the capability to save and restore settings that were previously applied to its structure using the $.jgrid.saveState and $.jgrid....
Read more >
How to configure redux-persist with redux-toolkit?
I have configured redux-persist with a traditional react-redux setup like this: onst persistConfig = { ...
Read more >
The Definitive Guide to Redux Persist - React Native Coach
The blacklist is added into the config object that we used when setting up our PersistReducer . const persistConfig = { key: 'root',...
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