Closed Petesta closed 7 years ago
In the README.md
there is a code snippet for creating a customer slicer. However, I think the code is wrong since in the source when you refer to your slicer
with var slicerFn = slicer(paths)
the code below...
function myCustomSlicer (paths) {
return (state) => {
let subset = {}
/*Custom logic goes here*/
return subset
}
}
Returns an object, not a function which is expected.
It seems like the code should be something of this sort.
function myCustomSlicer (paths) {
return (state) => {
let subset = {}
/*Custom logic goes here*/
return () => { subset }
}
}
Also, state
in these functions always happens to be a String
and not sure why. Shouldn't it be an object?
@elgerlambert could you give an example of how to include only certain inner keys ?
Here's how it needs to be done.
function customSlicer() {
return (state) => {
const { auth } = state;
return { auth };
}
}
compose(
applyMiddleware(thunk),
persistState(null, { slicer: myCustomSlicer() })
);
cool, thanks!
Any one is getting
TypeError: Object(...) is not a function
Hi, I'm struggling to figure out how to select a subset of what
config
needs to look like with keys/values inside ofpersistState
. 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 tolocalStorage
. Would you be able to elaborate more on how to accomplish this? My state currently looks like below.If I wanted to select
innerKey1
here, how would I go about that?