zIndex in FlatList
See original GitHub issueDescription
Related? #23614 #23615
Setting zIndex
on items of a FlatList
yields no result across different rows. However, it does work in the same row across it’s columns if existing.
I have tried using CellRenderComponent
without success.
This is crucial for dragging items in a list etc.
I can confirm it is cross platform. See the snack below.
React Native version:
React Native version
System:
OS: Windows 10 10.0.18362
CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Memory: 2.84 GB / 7.87 GB
Binaries:
Node: 12.14.0 - C:\Users\DELL\AppData\Local\Temp\yarn--1587809387421-0.6934667812958264\node.CMD
Yarn: 1.22.0 - C:\Users\DELL\AppData\Local\Temp\yarn--1587809387421-0.6934667812958264\yarn.CMD
npm: 6.13.4 - C:\Program Files (x86)\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 22, 23, 25, 26, 27, 28, 29
Build Tools: 23.0.1, 23.0.3, 24.0.1, 26.0.2, 27.0.1, 27.0.3, 28.0.0, 28.0.3, 29.0.3, 30.0.0
System Images: android-22 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom_64, android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-25 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-26 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-R | Google APIs Intel x86 Atom, android-R | Google Play Intel x86 Atom_64
Android NDK: 17.2.4988734
IDEs:
Android Studio: Version 3.5.0.0 AI-191.8026.42.35.5791312
Languages:
Java: 1.8.0_172 - C:\Program Files\Java\jdk1.8.0_172\bin\javac.EXE
Python: 3.6.5 - C:\Users\DELL\AppData\Local\Programs\Python\Python36-32\python.EXE
npmPackages:
@react-native-community/cli: Not Found
react: ^16.13.0 => 16.13.1
react-native: ^0.62.2 => 0.62.2
npmGlobalPackages:
*react-native*: Not Found
Done in 13.98s.
Steps To Reproduce
- Render a list of items with
FlatList
. - Change items’ position and
zIndex
so an item should render above other items placed after it in the list (descendingzIndex
).
Expected Results
zIndex
should behave the same in FlatList
items as it does in other view hierarchies. Meaning a greater value should result in rendering above other views.
Snack, code example, screenshot, or link to a repository:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:14
- Comments:22 (1 by maintainers)
Top Results From Across the Web
react-native: components with zIndex in flatlist does not seem ...
If I remove absolute form container, It shows. But I want show it in middle of screen (not middle of flatlist). But why...
Read more >Using methods like zIndex in React Native to stack elements
In React Native, you can use zIndex, position, Flatlist, and other methods to stack and position elements. Let's explore some examples.
Read more >Stacking overlapping views with zIndex in Expo and React ...
Learn how to stack overlapping views with zIndex. zIndex is the Expo and React Native analog of CSS's z-index property which lets the...
Read more >Flatlist Items does not work properly when they are on ... - Reddit
Flatlist Items does not work properly when they are on the same orientation ,changing zIndex does not work (I can't access Text Input...
Read more >Layout Props - React Native
zIndex controls which components display on top of others. Normally, you don't use zIndex . Components render according to their order in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
I am having the same issue. (I am trying to implement a drag-and-drop sort FastList) Setting
zIndex
inside the renderItem function does not work.I also tried to use
CellRendererComponent
and set the zIndex in the Wrapping component, but that would block my animations for some reason.I finally made it work by making sure that
CellRendererComponent
is always the exact same instance of the function across re-renders.Here is a simplified version of my code
In a functional component, you would probably want to use useCallback.
Hope that helps
Check out how it behaves across rows/columns.
zIndex
works in the row but not across rows.