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

Why does MobX 5 array still have the index violation issue? #1822

Closed
2 tasks done
vilicvane opened this issue Nov 23, 2018 · 7 comments
Closed
2 tasks done

Why does MobX 5 array still have the index violation issue? #1822

vilicvane opened this issue Nov 23, 2018 · 7 comments

Comments

@vilicvane
Copy link

I have a:

  1. Question: Feel free to just state your question. For a quick answer, there are usually people online at our Gitter channel
  2. Issue
[mobx.array] Index out of bounds, 1 is larger than 0

https://runkit.com/embed/56jty1h3u27y

@mweststrate
Copy link
Member

There are a few reasons

  1. Nobody took the effort to remove it :)
  2. This keeps feature parity between MobX 4 and 5, so that it is easier to migrate from 5 back to 4, if your browser support for example demands it
  3. Imho out-of-bound assignments that result in sparse arrays are a bad practice anyway :).

@vilicvane
Copy link
Author

@mweststrate The 2nd reason doesn't look valid to me, because of the 3rd one (as most of the time we don't write out-of-bound assignment). 😂

I am encountering this because of a third-party library https://github.com/flitbit/diff:

elements in arrays are now processed in reverse order, which fixes a few nagging bugs but may break some users

Will happy to send a PR for this if you like.

@mweststrate
Copy link
Member

mweststrate commented Nov 30, 2018 via email

@vilicvane
Copy link
Author

@mweststrate It's happening on applying changes to existing object. Related issue flitbit/diff#47

I don't see why slice would solve this issue, but fortunately there is an alternative to this functionality in my inventory that works with MobX.

@mweststrate
Copy link
Member

mweststrate commented Nov 30, 2018 via email

@vilicvane
Copy link
Author

@mweststrate Ahh, unfortunately not a simple workaround in my case. The object structure is unpredictable (it's like updating/restoring custom objects between versions). Thanks though.

@lock
Copy link

lock bot commented Jul 21, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants