-
Notifications
You must be signed in to change notification settings - Fork 642
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
resolveIdentifier regression issue after upgrading from 3.0.2 to 3.2.2 #1019
Comments
RainerAtSpirit
changed the title
resolveIdentifier regression issue after upgrading from 3.0.,2 to 3.2.2
resolveIdentifier regression issue after upgrading from 3.0.2 to 3.2.2
Sep 19, 2018
I took a look into it, it seems your id generator does not pass the test for the TOptionalId refinement |
nevermind, it seems to be about the identifier being optional with a function, looking further into it |
unit test test("#1019", () => {
function randomUuid() {
return "1bbc17fd-2068-4cc9-aff0-82d37c9cdf20"
}
const CommentModel = types.model("CommentModel", {
uid: types.optional(types.identifier, randomUuid)
})
const CommentStore = types
.model("CommentStore", {
items: types.array(CommentModel)
})
.actions(self => {
function test() {
const comment = CommentModel.create({})
expect(comment.uid).toBe(randomUuid())
self.items.push(comment)
const item = resolveIdentifier(CommentModel, self.items, comment.uid)
const item2 = self.items.find(i => i.uid === comment.uid)
expect(item).toBe(item2)
}
return {
test
}
})
CommentStore.create({}).test()
}) |
I had a similar (I think) issue today, a minimal repro is const Item = types
.model({
id: types.optional(types.identifier, 'dummykey'),
})
console.log(getIdentifier(Item.create())) // undefined, should be 'dummykey' |
xaviergonz
added
bug
Confirmed bug
has PR
A Pull Request to fix the issue is available
labels
Sep 19, 2018
The PR I just opened should fix both issues |
should be fixed in the recently released 3.4.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have:
MST3.0.2
resolveIdentifier
working:https://codesandbox.io/s/24zrq4n9n0 (models.CommentStore.js, line 15...)
Regression issue: After upgrading to MST3.2.2
resolveIdentifier
returns undefinedhttps://codesandbox.io/s/294ylryp0
Not following the above template might result in your issue being closed without further notice
The text was updated successfully, but these errors were encountered: