I'm writing a custom renderer using react reconciler.
My renderer should call computeLayout
when the tree got some changes.
I can insert computeLayout
function call at the tail of appendChild
, removeChild
, commitUpdate
which causes changes in the tree. But it would be painfully inefficient when there are multiple calls of those functions triggered by a single state update.
What I need is some sort of batching.
But if I use requestanimationframe
to batch computeLayout
, then users can see the wrong layout for a moment.
I want react reconciler to call my computeLayout
after every tree modification is applied and just before it terminates allowing browsers to apply all DOM updates.
Do we have such a callback method? Can I use resetAfterCommit
method in this case?