jotaijs / jotaijs/jotai-devtools

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

Open
#24 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
185
Forks
39
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the issue with useAtomsDevtools() and useSetAtom() without useAtom() or useAtomValue(), then inspect the useAtomsDevtools() subscription behavior and compare it with the useStore() workaround using store.sub(atom, () => {}). Done means the atom appears in Redux Devtools without requiring useAtomDevtools() or causing unnecessary component re-rendering.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.