I was just thinking about this today. I believe that while it ‘breaks the rules’, there’s nothing that React could do to tell the difference between the two.
So while it breaks the rules, if you have a good enough reason, understand the risks, then the ‘rules’ is just dogma.
React basically knows which useEffect hook is which, by counting invocations. Calling useEffect conditionally is bad, specifically because the amount of times useEffect gets called cannot change.
Your example is conditional, but React can’t detect it because in either condition you call it once.
However, the example you mention seems like it doesn’t need this. There’s good reasons to do things the ‘normal’ way, because as you can see from other commenters here, it causes confusion and surprise, and we don’t like surprise =)
If you are lazily loading in some functionality, just have your useEffect hook call the function when it is ready.