tldraw/packages/state/src/lib/react/useLayoutReaction.ts
David Sheldrick 8e23a253fc
[perf] Reinstate render throttling (#3160)
Follow up to #3129 

### Change Type

<!--  Please select a 'Scope' label ️ -->

- [x] `sdk` — Changes the tldraw SDK

- [x] `improvement` — Improving existing features



### Test Plan

1. Add a step-by-step description of how to test your PR here.
2.

- [ ] Unit Tests
- [ ] End to end tests

### Release Notes

- Add a brief release note for your PR here.
2024-03-15 16:18:23 +00:00

10 lines
340 B
TypeScript

import React from 'react'
import { useTrackedScheduler } from './useTrackedScheduler'
/** @internal */
export function useLayoutReaction(name: string, effect: () => void): void {
const scheduler = useTrackedScheduler(name, effect)
// eslint-disable-next-line react-hooks/exhaustive-deps
React.useLayoutEffect(scheduler.maybeExecute)
}