If the store or selector has been changed (as part of component props or state) this will have already triggered a re-render by React anyway.
At this point, the selected value can be derived from state, without also setting state and therefore triggering a re-render.
Perhaps the state held by useSelected (and used to force a re-render on change to selected) should not be the selected value itself. This is a derived value and doesn't need to re-render when the store or selector has changed, only when a store write has changed it independently of these two values.
Nevertheless it needs to have the 'means' of triggering a re-render when store state HAS caused the selected value to change.
If the store or selector has been changed (as part of component props or state) this will have already triggered a re-render by React anyway.
At this point, the selected value can be derived from state, without also setting state and therefore triggering a re-render.
Perhaps the state held by useSelected (and used to force a re-render on change to selected) should not be the selected value itself. This is a derived value and doesn't need to re-render when the store or selector has changed, only when a store write has changed it independently of these two values.
Nevertheless it needs to have the 'means' of triggering a re-render when store state HAS caused the selected value to change.