SolidJSS
SolidJSβ€’2y agoβ€’
5 replies
Fantasy

Removing element from store array doesn't remove rendered items

Hi, i need help with this.

I have a store that is shared in a context with some helper functions. I use the below function to add/remove tags (string array).

  const mutateTag = (id: string, tagname: string, type: string) => {
    setRef(
      (meta) => meta.metadata.id === id,
      'metadata',
      'tags',
      produce((tags) => {
        if (type === 'add') {
          tags?.push(tagname);
        }
        if (type === 'remove') {
          tags = tags?.filter((tag) => tag !== tagname);
        }
      }),
    );
  };


when i add tags to the store, it updates well and new items show up

            <Show when={props.metadata.tags}>
              <For each={props.metadata.tags}>
                {(tag) => (
                  <ViewBoxTag name={tag} removeTag={removeTag}>
                    {tag}
                  </ViewBoxTag>
                )}
              </For>
            </Show>


but when i remove the tags, the items are still visible
Was this page helpful?