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

Persist Array in React Native, empty string? -- can't repro #29

Closed
gHashTag opened this issue May 7, 2021 · 3 comments
Closed

Persist Array in React Native, empty string? -- can't repro #29

gHashTag opened this issue May 7, 2021 · 3 comments
Labels
kind: support Asking for support with something or a specific use case solution: can't repro An attempt to reproduce has been tried and failed solution: duplicate This issue or pull request already exists solution: needs test This issue requires creating a test to assuredly close out

Comments

@gHashTag
Copy link

gHashTag commented May 7, 2021

Why if I add mst-persist all keys are kept except finishArr which becomes an empty string?

Isn't it possible to store arrays in it?

const Dice = types
.model('Dice', {
    startGame: types.boolean,
    count: types.number,
    players: types.number,
    message: types.string,
    multi: types.number,
    finishArr: types.array(types.boolean)
  })
  
const DiceStore = Dice.create({
  startGame: false,
  count: 6,
  players: 1,
  message: ' ',
  multi: 0,
  finishArr: [true, true, true, true, true, true]
})

persist('@DiceStore', DiceStore, {
  storage: AsyncStorage, // AsyncStorage for React-Native, localStorage for web
  jsonify: true, // Set to true if using AsyncStorage
  whitelist: ['startGame', 'count', 'players', 'message', 'multi', 'gamer', 'finishArr'] // only these keys will be persisted
})
@agilgur5
Copy link
Owner

Sorry for not responding to this timely. My GitHub status at the time mentioned I was taking a break from OSS due to toxicity and abuse. Coming back now per my current status.

Getting to the question at hand, this might be due to #5. Currently data from create is actually not persisted. A way to check against #5 would be to make a change to DiceStore.finishArr (e.g. via an action) and see if that change is later persisted. If a change is persisted, then this would just be a duplicate of #5. If it isn't persisted, well then this could be a bug.

I need to make a reproduction environment for this package as currently behaviors in issues can be really hard to reproduce 😕

@agilgur5
Copy link
Owner

A test with arrays would also help validate this scenario. In general, tests with more complicated shapes would be helpful

@agilgur5 agilgur5 added the solution: needs test This issue requires creating a test to assuredly close out label Jul 19, 2023
@agilgur5
Copy link
Owner

Added an array test in #38 which passes successfully, so I can't reproduce this. I'm gonna guess this might have been due to lack of merge strategies, i.e. #5

@agilgur5 agilgur5 changed the title Persist Array in React Native Persist Array in React Native, empty string? -- can't repro Jul 19, 2023
@agilgur5 agilgur5 added solution: duplicate This issue or pull request already exists solution: can't repro An attempt to reproduce has been tried and failed kind: support Asking for support with something or a specific use case labels Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: support Asking for support with something or a specific use case solution: can't repro An attempt to reproduce has been tried and failed solution: duplicate This issue or pull request already exists solution: needs test This issue requires creating a test to assuredly close out
Projects
None yet
Development

No branches or pull requests

2 participants