From c1da8e3e8b5f6d7e80b73851104c36dc36aa6deb Mon Sep 17 00:00:00 2001 From: tech_e Date: Thu, 26 Dec 2024 16:01:07 -0700 Subject: [PATCH] Refactor UseParent to validate callback function before execution --- src/use/use.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/use/use.js b/src/use/use.js index f8e5301..6b64772 100644 --- a/src/use/use.js +++ b/src/use/use.js @@ -52,6 +52,13 @@ const Comment = (props) => BaseComment({ */ export const UseParent = (...args) => { + const settings = [...args]; + const callBack = settings.pop(); + if (typeof callBack !== 'function') + { + return; + } + /** * This will create a comment to use as a placeholder * to keep the layout in place. @@ -59,12 +66,6 @@ export const UseParent = (...args) => return Comment({ onCreated: (ele, parent) => { - const settings = [...args]; - const callBack = settings.pop(); - if (typeof callBack !== 'function') - { - return; - } updateLayout(callBack, ele, parent); } });