SolidJSS
SolidJSโ€ข3y agoโ€ข
15 replies
vik

How to array.filter Signal with array and pass down as Signal

I have a component:

export function ComboBox({
  options,
  selected,
  setSelected,
}

// with 
  createEffect(() =>
    setFilteredOptions(
      options.filter((option) =>
        option.label.toLowerCase().includes(searchTerm().toLowerCase())
      )
    )
  );

// returns combox with div, ul, li...


That's how I call it
  onMount(async () => {
    const [categories, levels] = await Promise.all([
      getCategories(locale) as Promise<Category[]>,
      getLevels(locale) as Promise<Level[]>,
    ]);

    setData({
      categories,
      levels,
    });
  });

return...
          <ComboBox
              options={categories().filter((c) => !c.parent) || []}
            selected={selectedCategory}
            setSelected={setSelectedCategory}
            placeholder="Select a category"
          />



This was working with solidstart and routedata/createServerDta$, but now I have to use solidjs. I think it was working, because of ssr
I think my Combox createEffect is never been called because options that I hand over is not a Signal anymore.

So what would be an optimal strategy?
Was this page helpful?