Closed Esxiel closed 3 years ago
I've tried to apply the same fix, but seems to not be working
This addresses the issue where in v0.63.0 you get a warning of Functions are not valid as a React child ...
and nothing within the KeyboardAwareScrollView renders.
Full warning description
Can you define not working? Is the same warning still showing up? Or did the warning disappear but your elements are not rendering? Or perhaps you mean the HOC isn't working?
It's not rendering the elements.
Working here!
I'm using this change via patch-package
patches/react-native-keyboard-aware-scroll-view+0.9.1.patch
diff --git a/node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js b/node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js
index 4bf0ed0..c17e886 100644
--- a/node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js
+++ b/node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js
@@ -545,8 +545,10 @@ function KeyboardAwareHOC(
// Allow to pass options, without breaking change, and curried for composition
// listenToKeyboardEvents(ScrollView);
// listenToKeyboardEvents(options)(Comp);
-const listenToKeyboardEvents = (configOrComp: any) => {
- if (typeof configOrComp === 'object') {
+const listenToKeyboardEvents = (configOrComp: React.ReactElement | KeyboardAwareHOCProps) => {
+ if (configOrComp?.displayName === "ScrollView") {
+ return KeyboardAwareHOC(configOrComp)
+ } else if (typeof configOrComp === 'object') {
return (Comp: Function) => KeyboardAwareHOC(Comp, configOrComp)
} else {
return KeyboardAwareHOC(configOrComp)
Thank you @Esxiel !
Thank you for notifying me that it works, I thought there was a use-case that I broke or something. @Fausto95 can't say for sure why it's not working for you, but if you don't/didn't have the Functions are not valid as a React child ...
problem, then the problem you're facing is probably a different one.
Perhaps styling problems? I had faced similar problems of elements not rendering simply due to my mistake on the styling...
I have forked the repo to fix this issue.
npm i @codler/react-native-keyboard-aware-scroll-view
working for me too
@Esxiel @codler thanks for your PRs
Is it safe to consider that this PR is a duplicate of https://github.com/APSL/react-native-keyboard-aware-scroll-view/pull/442 (merged now) ?
Thanks
Fixes issue on #429 ...while also still supporting the HOC usage