From 4b7380385418ab8876ca97afdc2753e913555010 Mon Sep 17 00:00:00 2001 From: Vincent de Lafontaine Date: Mon, 28 Apr 2025 18:45:05 -0400 Subject: [PATCH] fix(SmartScroll): allowuseoftextinputs --- src/Provider.tsx | 20 +++++++++++++++++--- src/index.tsx | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Provider.tsx b/src/Provider.tsx index 83e84f1..325adf2 100644 --- a/src/Provider.tsx +++ b/src/Provider.tsx @@ -162,11 +162,25 @@ const SmartScrollProvider = ({ children }: { children: React.ReactNode }) => { export const useSmartScrollContext = () => { const context = React.useContext(SmartScrollContext); + const scrollY = useSharedValue(0); + const wrapperRef = React.useRef(null); + const scrollRef = useAnimatedRef(); if (!context) { - throw new Error( - 'Component must be wrapped in a SmartScrollProvider. Please ensure the provider is included.' - ); + return { + scrollRef, + scrollY: scrollY, + isReady: false, + wrapperRef, + wrapperOffset: 0, + setWrapperOffset: () => null, + elements: {}, + setElements: () => null, + inputs: {}, + setInputs: () => null, + currentFocus: undefined, + clearFocus: () => null, + }; } return context; diff --git a/src/index.tsx b/src/index.tsx index 26825b7..4856090 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -9,5 +9,5 @@ export const MagicScroll = { ViewWrapper, TextInput, withSmartScroll, - SmartScrollView, + ChainingProvider: SmartScrollView, };