From 58f04685addab8f9502cad2c1cd08d4c7f48f941 Mon Sep 17 00:00:00 2001 From: Cole Lawrence Date: Mon, 18 Jul 2022 21:00:42 -0400 Subject: [PATCH] r3f: Accept function for objRef like for setState --- packages/r3f/src/main/editable.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/r3f/src/main/editable.tsx b/packages/r3f/src/main/editable.tsx index 07f5a8b..a2b6560 100644 --- a/packages/r3f/src/main/editable.tsx +++ b/packages/r3f/src/main/editable.tsx @@ -76,7 +76,10 @@ const createEditable = ( allRegisteredObjects.add(sheetObject) setSheetObject(sheetObject) - if (objRef) objRef!.current = sheetObject + if (objRef) + typeof objRef === 'function' + ? objRef(sheetObject) + : (objRef.current = sheetObject) editorStore.getState().addEditable(storeKey, { type: actualType,