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

The "store(Model, { id: value })" descriptor does not resolve "id" correctly to the model instance. #240

Closed
Qsppl opened this issue Mar 20, 2024 · 3 comments
Labels
bug store Applies to the store feature

Comments

@Qsppl
Copy link
Contributor

Qsppl commented Mar 20, 2024

const resolveId = options.id

const resolveId = options.id
    ? options.id
    : (host, value) => {
        if (value !== null && typeof value === "object") return value.id;
        return value ? String(value) : undefined;
      };

The resolveId function resolves 0 to undefined, but expects 0 to resolve to "0".
This causes the error TypeError: Provided model definition requires non-empty id: "undefined".
Example: https://codepen.io/qsppl/pen/rNbyOrm?editors=1010

@smalluban smalluban added bug store Applies to the store feature labels Mar 20, 2024
@smalluban
Copy link
Contributor

smalluban commented Mar 20, 2024

Thanks for raising this up, fixed in bbf280b

Plase update to v8.2.12

@Qsppl
Copy link
Contributor Author

Qsppl commented Mar 20, 2024

Thank you

@Qsppl
Copy link
Contributor Author

Qsppl commented Mar 20, 2024

Solving this error resulted in another error that I can't find.

The component with model { id: 0, ... } now receives a model, but then loses it:
https://codepen.io/qsppl/pen/jORBqed?editors=1010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug store Applies to the store feature
Development

No branches or pull requests

2 participants