In a custom hook, I forgot to wrap my `setState` call in a `useEffect`, which did not pose any problems prior to React 18 but now this does not work anymore. The component does not re-render if the store is changed back to its initial value. I guess this might be expected, but there was no warning whatsoever, so it was hard to find out.

So this is more like a question:
- Is that behavior a bug?
- If it is not, would it be useful to have a warning for another developer making the same mistake?

React version: 18
## Steps To Reproduce

1. Have a component use `useSyncExternalStore` (for example redux 8)
2. Call `setState` outside of `useEffect` or event handlers (in render)
3. Trigger a change to the store back and forth

Link to code example: https://codesandbox.io/s/react-18-redux-8-reproduce-bug-ojdx43

## The current behavior

- The component does re-render if the store value is updated to something different than its initial value
- The component **does not** re-render if the store is updated to its initial value again

## The expected behavior

- The component does re-render if the store value is updated to something different than its initial value
- The component **also does** re-render if the store is updated to its initial value again

## Further digging

When I tried to trace down the issue, I found that the `setState` called outside `useEffect` would mess up with the fiber update queue, in particular the prior `pushEffect` supposedly calling `updateStoreInstance` with the latest value to have the internal cached instance up to date. It does not get called at all (cancelled? overridden?) because of the unwrapped `setState`.

As a consequence, that cached instance never gets updated. Any other value but the initial value hence correctly triggers a re-render, as the `checkIfSnapshotChanged` ends up always comparing against that initial value. 
impl: F,
  },
  nextImpl: F,
};
export type FunctionComponentUpdateQueue = {
  lastEffect: Effect | null,
  events: Array<EventFunctionPayload<any, any, any>> | null,
  stores: Array<StoreConsistencyCheck<any>> | null,
  
  memoCache?: MemoCache | null,
};
type BasicStateAction<S> = (S => S) | S;
type Dispatch<A> = A => void;
let renderLanes: Lanes = NoLanes;
let currentlyRenderingFiber: Fiber = (null: any);
let currentHook: Hook | null = null;
let workInProgressHook: Hook | null = null;
let didScheduleRenderPhaseUpdate: boolean = false;
let didScheduleRenderPhaseUpdateDuringThisPass: boolean = false;
let shouldDoubleInvokeUserFnsInHooksDEV: boolean = false;
let localIdCounter: number = 0;
let thenableIndexCounter: number = 0;
let globalClientIdCounter: number = 0;
const RE_RENDER_LIMIT = 25;
let currentHookNameInDev: ?HookType = null;
let hookTypesDev: Array<HookType> | null = null;
let hookTypesUpdateIndexDev: number = -1;
 In DEV, this tracks whether currently rendering component needs to ignore
 the dependencies for Hooks that need them (e.g. useEffect or useMemo).
 When true, such Hooks will always be "remounted". Only used during hot reload.