Skip to content

Old Data render #4320

Closed Answered by ekwoka
njfamirm asked this question in 1. Help
Jul 28, 2024 · 3 comments · 13 replies
Discussion options

You must be logged in to vote

I honestly cannot tell what this is trying to do or what you are saying isn't working.

You do what and what doesn't change?

You can just use Alpine.$persist to handle syncing to local storage instead of writing all that monstrous code there.

But I think the main issue is that your data is locking in a selected value when it runs, and you never change it.

So

alpine.data('productItem', (category: ProductCategory, productId: string) => {
-  const selected = cartStore.store.findIndex(category as ProductCategory, productId) !== -1;
  return {
-    selected,
+   get selected() {
+         return cartStore.store.findIndex(category as ProductCategory, productId) !== -1;
+   }
  };
});

I don't rea…

Replies: 3 comments 13 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
13 replies
@ekwoka
Comment options

@SimoTod
Comment options

SimoTod Jul 30, 2024
Collaborator

@njfamirm
Comment options

@ekwoka
Comment options

@njfamirm
Comment options

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