question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Button height is shrunk when initially mounted, but fixed when re-rendered

See original GitHub issue

Current behaviour

I’m using the Button component and when the screen is initially mounted, the button is about half the height of normal. When the screen is re-rendered, the button is fixed and renders normally.

Expected behaviour

The button would render normally at full height on mount / first render.

Code sample

            <View
              style={{
                flexDirection: "row",
                width: "100%",
                justifyContent: "space-evenly",
                alignItems: "center",
              }}
            >
              <Button
                mode="contained"
                textColor={"#fff"}
                compact
                disabled={
                  newPath.name.length === 0 || newPath.map_coords.length < 2
                }
                dark={true}
                onPress={() => savePath()}
              >
                SAVE
              </Button>
              <Button
                mode="contained"
                textColor={colors.darkRed}
                compact
                labelStyle={{ fontWeight: "bold" }}
                style={{
                  backgroundColor: colors.lightGray,
                }}
                dark={true}
                onPress={() => deletePath()}
              >
                {route.params?.travelPath ? "DELETE" : "CANCEL"}
              </Button>
            </View>

Screenshots (if applicable)

on mount: image

after re-render: image

What have you tried

changing style props on the button components, as well as the parent elements to include flex: 1, height: “100%”, etc. Toggling compact doesn’t make any difference either.

Your Environment

software version
ios or android ios and android
react-native 0.69.4
react-native-paper 5.0.0-rc.4
node v16.14.0
npm or yarn yarn
expo sdk 6.0.1

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jjrisecommented, Aug 23, 2022

I changed to a different bottom sheet and the issue is resolved. My apologies for stirring this up, but want to follow up in case this trips up anyone else in the future.

0reactions
jjrisecommented, Aug 23, 2022

Hey @jjrise, could you please try to reproduce the issue on the snack?

Yes, I will start putting that together now. One thing that is probably worth noting, these buttons are inside a Bottom Sheet. Not sure if it’s related, but the bottom sheet has been suspect for UI issues in the past.

https://github.com/gorhom/react-native-bottom-sheet

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rerender view on browser resize with React - Stack Overflow
Above solutions do work BUT will re-render your components whenever the window size changes by a single pixel. This often causes performance issues...
Read more >
cy.click() failed because element is effective width and height ...
Before I begin Typing into the field, I ensure the field is visible, and then try to type, but I get the same...
Read more >
React key attribute: best practices for performant lists
Looking into how React "key" attribute works, how to use it correctly, ... But in “index"-based list on the left items are only...
Read more >
A Story of a React Re-Rendering Bug - Engineering Blog
The next step is to investigate what exactly goingis on and find solutions to fix it. First, let's look at the component from...
Read more >
Hooks FAQ - React
You can't use Hooks inside a class component, but you can definitely mix classes and function components with Hooks in a single tree....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found