Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Allow flushSync to noop in life cycles but with a warning #18759
We already did this for flushControlled before.
It doesn't make sense to flush in a life-cycle or render because React can't do the work right then. Even if we did, it would make all other life-cycles more confusing.
There might be some opportunity by flushing right at the end of a React batch to do a second one. However, you can also call flush sync in the next tick to get more or less the same effect.
The only reason to relax this to a log is that it is very easy to accidentally add this to paths called from life-cycles since anything could call it. It might just be able to work in most cases.
In the case it's called from a layout effect, the priority of scheduled work will be sync anyway. In the case where it's called in passive effects, I could increase the priority but that's just a fallback case. It errors anyway. If it's in passive effects it full of race conditions anyway so probably it's fine to leave it like this.