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

Unexpected margin/spaces above ListHeaderComponent #201

Open
bryanprimus opened this issue Jan 11, 2023 · 1 comment
Open

Unexpected margin/spaces above ListHeaderComponent #201

bryanprimus opened this issue Jan 11, 2023 · 1 comment

Comments

@bryanprimus
Copy link

I have this code that uses FlatGrid component

<FlatGrid
  data={[1, 2, 3, 4]}
  renderItem={() => <Text>Hello world</Text>}
  style={{ backgroundColor: 'red' }}
  ListHeaderComponent={
    <Box>
      <Text fontSize="xl">HELLO HEADER</Text>
    </Box>
  }
  ListHeaderComponentStyle={{ backgroundColor: 'white' }}
  stickyHeaderIndices={[0]}
/>

It renders like this
image

not sure why that spaces were added. but it's not appear when i change it to FlatList

@saleel
Copy link
Owner

saleel commented Jan 14, 2023

Oh true. There is a spacing (10 units default) that is applied the to the grid - between the items and outside. Internally this is a padding/margin at the top of container and ListHeaderComponents is getting rendered inside.

I will look in to this and see what can be done, without affecting other stuffs.

For now you can do a quick hack I suppose

ListHeaderComponentStyle={{ backgroundColor: 'red', marginTop: -10, marginBottom: 10 }}

Replace 10 with value you provide for spacing prop if you change it.

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

No branches or pull requests

2 participants