79639776

Date: 2025-05-27 03:32:54
Score: 3.5
Natty:
Report link

1- Why is this happenning with Zustand?
That is not because of Zustand itself, but because of how React re-runs hooks.
2- How can I fix this?
You wrote this:

const [config, setConfig] = useSafeState<ConfigData>({
  mode: ListModeEnum.CREATE_SHOPPING_LIST,
  listType: ListTypeEnum.SHOPPING_LIST,
  visible: false,
});

This might happen especially if you're not memoizing the useLists() hook return or structure.
You need to make sure that initialState is not recomputed on every render.

const initialConfig = useMemo(() => ({
  mode: ListModeEnum.CREATE_SHOPPING_LIST,
  listType: ListTypeEnum.SHOPPING_LIST,
  visible: false,
}), []);

const [config, setConfig] = useSafeState<ConfigData>(initialConfig);

you can check this , if this not work , let me know

Reasons:
  • Blacklisted phrase (0.5): How can I
  • Blacklisted phrase (1): How can I fix this
  • RegEx Blacklisted phrase (1.5): How can I fix this?
  • RegEx Blacklisted phrase (0.5): Why is this
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: Julian