Skip to content
Discussion options

You must be logged in to vote

Hi @iErKy I think that the problem you have is not due to trackById directive but the toSignal stictness.
Becouse even if you are using an observable that will immediately emit the array, in you use-case the toSignal(ob$) has type: ExampleItem[] | undefined and this will generate the error on trakById that need all items to have a prop named id the undefined will fail this and generate error.

To fix the error in your specific case you can do something like this (if you know that you have an Observable that immediately emit values like of([item1, item2])

const FAKEITEMS: ExampleItem[] =[
  { id: '1', name: 'item1' },
  { id: '2', name: 'item2' },
];

  $items = toSignal(
    of(FAKEITEMS), { 

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@iErKy
Comment options

@iErKy
Comment options

Comment options

You must be logged in to vote
2 replies
@iErKy
Comment options

@dmorosinotto
Comment options

Answer selected by iErKy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants