No, I think what you see is expected when using reacts StrictMode component.
Detecting unexpected side effects
React does work in two phases, a "render" phase and a "commit" phase.
- The render phase determines what changes need to be made to e.g. the DOM. During this phase, React calls
render and then compares the result to the previous render. - The commit phase is when React applies any changes. (In the case of React DOM, this is when React inserts, updates, and removes DOM nodes.) React also calls lifecycles like
componentDidMount and componentDidUpdate during this phase.
React can invoke the render phase more than once prior to committing.
Strict mode can’t automatically detect side effects for you, but it can help you spot them by making them a little more deterministic. This is done by intentionally double-invoking the following functions:
- Class component constructor, render, and shouldComponentUpdate methods
- Class component static getDerivedStateFromProps method
- Function component bodies
- State updater functions (the first argument to setState)
- Functions passed to useState, useMemo, or useReducer
The entire functional component body is the "render" function. The effect runs during the "commit" phase as a "lifecycle function".

This demo shows both at the same time.
- Notice there are several console logs from the with-StrictMode component, but only ever 2 with the without-StrictMode component.
- If you comment out the
useEffect hook and re-run the sandbox, notice there is a double logging from the Strictmode wrapped app and only a single from the unwrapped one.
What you will see is that there will always be at least one (more if running in StrictMode) log from the "render" phase, and always exactly one log from the useEffect which runs once per render cycle, i.e. the "commit" phase.
What is likely also compounding the issue is the fact that you are mutating the array reference and it is likely mutated with the new value by the time the console log buffer is flushed to output. Remember, the second console log in the return is the equivalent to a side-effect in a "render" function which should be a pure function. With this side-effect there are to be unexpected results, which is of course the entire point of the StrictMode.
tempgets redeclared on every render so it only logs and empty array for me. Not sure how you see the new element pushed.useEffectruns after the render, that's why it should print an empty array every time.