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, };