-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
pixel size (px) value of some style properties (padding, margin) may caused the app crash. #20206
Comments
But if I use the px value with some others style properties such as |
All dimensions in React Native are unitless, and represent density-independent pixels. That means instead of passing a string value to style properties that have measurements, you'll need to pass in a number. Looking back at your styles object you'll need to change const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
padding: 20,
},
}); |
@jamsch I know that, but I think it shouldn't cause the app broken without any error message. |
Feel free to open a PR for that, in the meantime I'm closing this since it works as expected 😶 |
I confirmed whether it reproduces on iOS or not. |
This will convert the absolute 20dp padding to 20px fixed. Useful for developers following a strict design spec or something like that. More info on PixelRatio |
Environment
Run
react-native info
in your terminal and paste its contents here.Description
Just create an new app, and only try to add
padding: '20px'
into the style of view, then it crashed and could not open again.Nothing error found, both the app and the Metro Bundler Console. When I connect the android log (react-native log-android), I just found that:
Reproducible Demo
The text was updated successfully, but these errors were encountered: