Good explanation here
Essentially, the problem boils down to the fact that in strict mode, React invokes some hooks twice (https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects). This is because it tries to detect invoking side-effects during the render phase as it leads to problems when using concurrent mode.