Skip to content

Invariant Violation: "//" is not a valid style property. #133

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

Closed
Zn4rK opened this issue Feb 8, 2020 · 4 comments
Closed

Invariant Violation: "//" is not a valid style property. #133

Zn4rK opened this issue Feb 8, 2020 · 4 comments

Comments

@Zn4rK
Copy link

Zn4rK commented Feb 8, 2020

styled.View`
  // background: green;
  background: red;
`;

Yields:

Invariant Violation: "//" is not a valid style property.
StyleSheet generated: {
  "//": "green",
  "backgroundColor": "red"
}
Valid style props: [
  "alignContent",
  "alignItems",
  "alignSelf",
  "aspectRatio",
   ...etc
]

StackTrace:

 at invariant (node_modules/invariant/invariant.js:40:15)
    at styleError (node_modules/react-native/Libraries/StyleSheet/StyleSheetValidation.js:77:3)
    at Function.validateStyleProp (node_modules/react-native/Libraries/StyleSheet/StyleSheetValidation.js:35:7)
    at Function.validateStyle (node_modules/react-native/Libraries/StyleSheet/StyleSheetValidation.js:55:28)
    at Object.create (node_modules/react-native/Libraries/StyleSheet/StyleSheet.js:355:30)
    at InlineStyle.generateStyleObject (node_modules/styled-components/native/dist/styled-components.native.cjs.js:5809:33)
    at StyledNativeComponent.generateAndInjectStyles (node_modules/styled-components/native/dist/styled-components.native.cjs.js:6037:24)
    at node_modules/styled-components/native/dist/styled-components.native.cjs.js:5991:36
    at updateContextConsumer (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:9740:19)
    at beginWork$1 (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:10123:14)

Relevant dependencies:

    "styled-components": "^5.0.1"
    "react-native": "^0.61.5",
    "react-test-renderer": "^16.12.0",
@Zn4rK
Copy link
Author

Zn4rK commented Feb 8, 2020

Closing this and opening in styled-components/styled-components instead. Feel free to reopen if it should be handled here.

@Zn4rK
Copy link
Author

Zn4rK commented Feb 17, 2020

Would it make sense to handle parsing of comments in this repository? I opened a PR with a failing test in styled-components - but @kitten thought it should be handled here.

@Zn4rK Zn4rK reopened this Feb 17, 2020
@jacobp100
Copy link
Contributor

Have a look at the API for this project - we only parse individual CSS properties and values as strings

To support this, it would need to be done at the CSS parser level. Also note that // comments aren't valid CSS, so you'd need a CSS parser that adds support for them

@Zn4rK
Copy link
Author

Zn4rK commented Feb 17, 2020

Cool! I agree - just wanted to make sure :)

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