Open daankennes opened 1 year ago
hi @daankennes any chance you could submit this as a PR?
I'm developing an app with this component and I'm seeing a similar flickering.
It's just as you describe: it renders and then recalculates its position while still visible. It's very un-aesthetic.
Hi @Zcehtro. I am currently on holiday. I can create a PR when I'm back (in a week). However, it is easy to apply the fix yourself or copy the diff and use patch-package.
Sadly the patch package snippet does no longer work. Does anyone have a fix for this?
I am using <Dropdown />
inside of screen that has animation(presentation: "modal"
from react-navigation
) and it looks like onLayout
is being called at times Dropdown does not have correct position and it causes flickering when we open it for the first time, so by removing onLayout Dropdown position is calculated correctly and displayed only when we have correct position
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-element-dropdown/src/components/Dropdown/index.tsx b/node_modules/react-native-element-dropdown/src/components/Dropdown/index.tsx
index 07bf17b..3ebfd90 100644
--- a/node_modules/react-native-element-dropdown/src/components/Dropdown/index.tsx
+++ b/node_modules/react-native-element-dropdown/src/components/Dropdown/index.tsx
@@ -661,7 +661,6 @@ const DropdownComponent: <T>(
<View
style={StyleSheet.flatten([styles.mainWrap, style])}
ref={ref}
- onLayout={_measure}
>
{_renderDropdown()}
{_renderModal()}
This issue body was partially generated by patch-package.
any updates about this problem?
Having same issue, I tried this patch but it doesn't solve it. I'm using the v.2.12.1
I am using
<Dropdown />
inside of screen that has animation(presentation: "modal"
fromreact-navigation
) and it looks likeonLayout
is being called at times Dropdown does not have correct position and it causes flickering when we open it for the first time, so by removing onLayout Dropdown position is calculated correctly and displayed only when we have correct positionHere is the diff that solved my problem:
diff --git a/node_modules/react-native-element-dropdown/src/components/Dropdown/index.tsx b/node_modules/react-native-element-dropdown/src/components/Dropdown/index.tsx index 07bf17b..3ebfd90 100644 --- a/node_modules/react-native-element-dropdown/src/components/Dropdown/index.tsx +++ b/node_modules/react-native-element-dropdown/src/components/Dropdown/index.tsx @@ -661,7 +661,6 @@ const DropdownComponent: <T>( <View style={StyleSheet.flatten([styles.mainWrap, style])} ref={ref} - onLayout={_measure} > {_renderDropdown()} {_renderModal()}
This issue body was partially generated by patch-package.
Hi!
Firstly, thanks for your work on this project! 🙂
EDIT: this only seems to happen on Android
Upon opening the dropdown, the position measurement is wrong and is then recalculated. However, the wrong position is used for a first render which makes the list slightly out of position for a split second (see image).
I solved the problem by waiting for the recalculation, but it is not optimal and I wonder why the initial position is wrong in the first place.
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.