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.

[RN] Failed to parse declaration of padding

See original GitHub issue

I have to use padding-vertical, padding-horizontal but I can’t use padding: [number];

Same for margin

Code example


const ComponentName = styled.View`
  padding: 5;  <--- this fails
`

screen shot 2017-12-08 at 9 02 36 am

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
yordiscommented, Dec 8, 2017

@philpl I am new into RN but as far as I know there is no px in RN right? Isn’t everything without unit?

Why those px because now I am super confuse. I wouldn’t use any metric using regular Stylesheet.create

2reactions
kittencommented, Dec 8, 2017

@yordis well, in fact, we’re basically removing complexity by making it more similar to vanilla CSS 😉 but that’s a matter of perspective.

The point is not that we do it because it’s a shorthand; We do it to differentiate between units inside shorthands. Otherwise we wouldn’t be able to recognise percentages and px values and be able to correctly translate them and split them up later.

Anyway, I hope I’ve helped you here, and feel free to checkout css-to-react-native if you have some suggestions or issues 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to show View within styled (using styled-components) View
1) When I set padding={10} , I get an error Failed to parse declaration "padding: 10" . 2) After Googling a bit, I...
Read more >
Failed To Parse Declaration "Background: Url(1): Using Styled ...
After investigating with @Trobyss we found an issue with styledcomponents after View backgroundcolor: red; padding: 20px; borderradius: 8px; flex: 1; margin: ...
Read more >
Using Styled Components with React Native - Level Up Coding
CSS properties such as padding and margin are used to add space between UI elements in relation to one another. This is the...
Read more >
How To Customize React Components with Props
PropTypes are a simple type system to check that data matches the expected types during runtime. They serve as both documentation and an...
Read more >
react-native-render-html - npm
react-native-render-html. TypeScript icon, indicating that this package has built-in type declarations. 6.3.4 • Public • Published a year ...
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