Skip to content

Atoms are not visible in Redux Devtools if the atom value is not used #24

@tmatz

Description

@tmatz

I am using useAtomsDevtools().

If I use useSetAtom() for atom in the react component and do not useAtom() or useAtomValue(), the atom is not displayed in the Redux Devtools.

As a workaround, I was able to display the atom in Redux Devtools by using the store obtained with useStore() and setting store.sub(atom, () => {}).

  const store = useStore();
  useEffect(() => {
    if (process.env.NODE_ENV !== 'production') {
      return store.sub(myAtom, () => {
        // nop
      });
    }
    return undefined;
  }, [store]);

Although useAtomDevtools() will allow you to display with the Redux Devtools, we prefer not to use it because it causes unnecessary re-rendering.

It would be nice if useAtomsDevtools() would also display the atom when useSetAtomValue() is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions