SolidJSS
SolidJSโ€ข2y agoโ€ข
25 replies
CatNoir

How can I use a custom hook with createMemo in many places?

I have created a hook like this:
// This is a hook
const useInMultiplePlaces =() => {
  
  const complicated = createMemo(() => {
    // something complicated
  })

  return {complicated}
}

I then use this hook in multiple active rendering components. the createMemo is probably ran multiple times everytime the useInMultiplePlaces hook is ran in those components.

Is there anyway to like... have like a key for this memo, and reuse the same memo.. idk what im saying but i hope you understand my issue ๐Ÿ˜ญ
Was this page helpful?