diff --git a/packages/react-native-executorch/src/hooks/natural_language_processing/useLLM.ts b/packages/react-native-executorch/src/hooks/natural_language_processing/useLLM.ts index f00927d6c7..5f861c033b 100644 --- a/packages/react-native-executorch/src/hooks/natural_language_processing/useLLM.ts +++ b/packages/react-native-executorch/src/hooks/natural_language_processing/useLLM.ts @@ -46,19 +46,19 @@ export const useLLM = ({ setDownloadProgress(0); setError(null); - if (!preventLoad) { + if (preventLoad) return; + + (async () => { try { - (async () => { - await model.load({ - modelSource, - tokenizerSource, - tokenizerConfigSource, - }); - })(); + await model.load({ + modelSource, + tokenizerSource, + tokenizerConfigSource, + }); } catch (e) { setError(e); } - } + })(); return () => { model.delete();