Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation on createTransform() #1423

Open
azerum opened this issue Dec 16, 2022 · 1 comment · May be fixed by #1446
Open

Improve documentation on createTransform() #1423

azerum opened this issue Dec 16, 2022 · 1 comment · May be fixed by #1446

Comments

@azerum
Copy link

azerum commented Dec 16, 2022

In current documentation about createTransform() it unclear inboundState and outboundState parameters are full redux states to be serialized/deserialized or a value of a field of the state:

import { createTransform } from 'redux-persist';

const SetTransform = createTransform(
  // transform state on its way to being serialized and persisted.
  (inboundState, key) => {
    // convert mySet to an Array.
    return { ...inboundState, mySet: [...inboundState.mySet] };
  },
  // transform state being rehydrated
  (outboundState, key) => {
    // convert mySet back to a Set.
    return { ...outboundState, mySet: new Set(outboundState.mySet) };
  },
  // define which reducers this transform gets called for.
  { whitelist: ['someReducer'] }
);

export default SetTransform;

As it turns out, each function has signature (fieldValue, key, state) => newValue. I think the documentation should describe all three parameters. I can submit PR later

@yixiaojiu
Copy link

This help me a lot.

azerum added a commit to azerum/redux-persist that referenced this issue Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants