390c45c7eb
This is an attempt at #1989. The big issue there is when `shapeUtils` change when you're relying on tldraw to provide you with the store instead of providing your own. Our `useTLStore` component had a bug where it would rely on effects & a ref to detect when its options had changed whilst still scheduling updates. Fresh opts would come in, but they'd be different from the ones in the ref, so we'd schedule an update, so the opts would come in again, but they'd still be different as we hadn't run effects yet, and we'd schedule an update again (and so on). This diff fixes that by storing the previous opts in state instead of a ref, so they're updating in lockstep with the store itself. this prevents the update loop. There are still situations where we can get into loops if the developer is passing in custom tools, shapeUtils, or components but not memoising them or defining them outside of react. As a DX improvement, we do some auto-memoisation of these values using shallow equality to help with this issue. ### Change Type - [x] `patch` — Bug fix ### Test Plan - [x] Unit Tests ### Release Notes - Fixes a bug that could cause crashes due to a re-render loop with HMR #1989 |
||
---|---|---|
.. | ||
lib | ||
index.ts |