SolidJSS
SolidJS3w ago
2 replies
Leander

Any way to snapshot DOM before signal updates?

Is there any public API or lifecycle hook that runs before DOM mutations for a signal update (like React’s class-component getSnapshotBeforeUpdate but for a specific signal and not a component rerender), so I can measure layout right before a reactive change?

This would be like hooking into the Setter of a signal and running something before changing the signal value, but some hook to do this universally for any Accessor or similar.

From my understanding createRenderEffect is the "earliest" effect we can use to hook into the update cycle but this still runs after the DOM has been mutated. Does the lifecycle before the DOM mutation even "exist" or is it really that signals immediately update the real DOM?
Was this page helpful?