Skip to content

Commit b913dfa

Browse files
authored
Merge pull request #3 from AppAndFlow/feature/allow-use-of-textInput-without-magic-scrollview
fix(SmartScroll): allowuseoftextinputs
2 parents 01ef9e9 + 4b73803 commit b913dfa

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/Provider.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,25 @@ const SmartScrollProvider = ({ children }: { children: React.ReactNode }) => {
162162

163163
export const useSmartScrollContext = () => {
164164
const context = React.useContext(SmartScrollContext);
165+
const scrollY = useSharedValue(0);
166+
const wrapperRef = React.useRef<View>(null);
167+
const scrollRef = useAnimatedRef<Animated.ScrollView>();
165168

166169
if (!context) {
167-
throw new Error(
168-
'Component must be wrapped in a SmartScrollProvider. Please ensure the provider is included.'
169-
);
170+
return {
171+
scrollRef,
172+
scrollY: scrollY,
173+
isReady: false,
174+
wrapperRef,
175+
wrapperOffset: 0,
176+
setWrapperOffset: () => null,
177+
elements: {},
178+
setElements: () => null,
179+
inputs: {},
180+
setInputs: () => null,
181+
currentFocus: undefined,
182+
clearFocus: () => null,
183+
};
170184
}
171185

172186
return context;

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export const MagicScroll = {
99
ViewWrapper,
1010
TextInput,
1111
withSmartScroll,
12-
SmartScrollView,
12+
ChainingProvider: SmartScrollView,
1313
};

0 commit comments

Comments
 (0)