Skip to content

It is possible to create derivations that can accept parameters #719

Closed Answered by batusai513
batusai513 asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for your response, I ended up using useMemo:

export function useIsComponentSelected(id: string) {
  const selectedIdState = useMemo(
    () =>
      derive({
        selected: (get) => {
          return get(rootState.pageComponentIdToEdit).id === id;
        },
      }),
    [id],
  );

  return selectedIdState;
}

this avoids infinite re-renders

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@batusai513
Comment options

Answer selected by batusai513
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants