balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

Taxonomies.js (508B)


      1 import create from 'zustand'
      2 
      3 export const useTaxonomyStore = create((set, get) => ({
      4     taxonomies: {},
      5     openedTaxonomies: [],
      6     setTaxonomies: (taxonomies) => set({
      7         taxonomies,
      8     }),
      9     // This is here because I couldn't get the sidebar components to hold state on re-render
     10     toggleOpenedTaxonomy: (tax, add) => {
     11         const opened = get().openedTaxonomies
     12         set({
     13             openedTaxonomies: add ? [...opened, tax] : [...opened.filter(t => t != tax)],
     14         })
     15     },
     16 }))