[IMP] component: disallow calling hooks outside of setup

(and constructor)

Doing so could cause strange and difficult bugs
This commit is contained in:
Géry Debongnie
2022-01-31 15:03:52 +01:00
committed by Aaron Bohy
parent 4d68dac24d
commit bd98d4d0d0
6 changed files with 54 additions and 17 deletions
+1 -1
View File
@@ -239,7 +239,7 @@ const batchedRenderFunctions = new WeakMap<ComponentNode, Callback>();
* @see reactive
*/
export function useState<T extends object>(state: T): Reactive<T> | NonReactive<T> {
const node = getCurrent()!;
const node = getCurrent();
if (!batchedRenderFunctions.has(node)) {
batchedRenderFunctions.set(
node,