5b21ad96ae
in many places, we use a pattern like `React.createContext({} as Editor)` when defining contexts. This causes a problem: `{}` is not `Editor`, but you can still `useEditor` wherever you like and your code with run with this confusing non-editor value. This diff updates all our `createContext` calls to default to `null`, with an explicit check and error for missing values. Now, if you `useEditor` outside of `<Tldraw />`, you'll get a message telling you that it can only be used within `<Tldraw />`. ### Change Type - [x] `sdk` — Changes the tldraw SDK - [x] `improvement` — Improving existing features ### Release Notes `useEditor` and other context-based hooks will now throw an error when used out-of-context, instead of returning a fake value. |
||
---|---|---|
.. | ||
assets | ||
dotcom-shared | ||
editor | ||
namespaced-tldraw | ||
state | ||
store | ||
tldraw | ||
tlschema | ||
tlsync | ||
utils | ||
validate |