const CollectionsView = () => {
const store: StoreState = useStore()
const params = useParams()
const [currentCollection, setCurrentCollection] = createSignal<Collection>()
const [currentCollaborators, setcurrentCollaborators] = createSignal<UserSummary[]>([])
createEffect(() => {
console.log(store.cards.collections)
let collection: Collection | undefined
= store.cards.collections.find(
(collection) => collection.id === params.collection_id
)
if (collection === undefined) {
collection = store.cards.sharedCollections.find(
(collection) => collection.id === params.collection_id
)
if (collection === undefined) {
navigate("/fcards")
return
}
}
batch(() => {
setCurrentCollection(collection)
setcurrentCollaborators(collection!.collaborators)
// this shows the correct value:
console.log("collaborators: ", currentCollaborators())
})
})
return (
// ...
// the following does not re-render with new changes
<For each={currentCollaborators()!}>
{(collaborator) => <div>{collaborator.display_name}</div>}
</For>
)
const CollectionsView = () => {
const store: StoreState = useStore()
const params = useParams()
const [currentCollection, setCurrentCollection] = createSignal<Collection>()
const [currentCollaborators, setcurrentCollaborators] = createSignal<UserSummary[]>([])
createEffect(() => {
console.log(store.cards.collections)
let collection: Collection | undefined
= store.cards.collections.find(
(collection) => collection.id === params.collection_id
)
if (collection === undefined) {
collection = store.cards.sharedCollections.find(
(collection) => collection.id === params.collection_id
)
if (collection === undefined) {
navigate("/fcards")
return
}
}
batch(() => {
setCurrentCollection(collection)
setcurrentCollaborators(collection!.collaborators)
// this shows the correct value:
console.log("collaborators: ", currentCollaborators())
})
})
return (
// ...
// the following does not re-render with new changes
<For each={currentCollaborators()!}>
{(collaborator) => <div>{collaborator.display_name}</div>}
</For>
)