Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix elements not rendering on v0.63.0 #441

Closed
wants to merge 1 commit into from
Closed

Conversation

Esxiel
Copy link

@Esxiel Esxiel commented Jul 9, 2020

Fixes issue on #429 ...while also still supporting the HOC usage

...while supporting the HOC usage
@Fausto95
Copy link

Fausto95 commented Jul 9, 2020

I've tried to apply the same fix, but seems to not be working

@Esxiel
Copy link
Author

Esxiel commented Jul 10, 2020

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?

@Fausto95
Copy link

It's not rendering the elements.

@davidgovea
Copy link

davidgovea commented Jul 11, 2020

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 !

@Esxiel
Copy link
Author

Esxiel commented Jul 12, 2020

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...

@codler
Copy link
Contributor

codler commented Jul 12, 2020

I have forked the repo to fix this issue.

npm i @codler/react-native-keyboard-aware-scroll-view

@patrickschmelter
Copy link

working for me too

@rborn
Copy link
Collaborator

rborn commented Jul 14, 2020

@Esxiel @codler thanks for your PRs

Is it safe to consider that this PR is a duplicate of #442 (merged now) ?

Thanks

@Esxiel Esxiel closed this Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants