Button height is shrunk when initially mounted, but fixed when re-rendered
See original GitHub issueCurrent 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:
after re-render:
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:
- Created a year ago
- Comments:5 (1 by maintainers)
Top 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 >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
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.
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