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.

Question: How to write styles with a deep structure in react native?

See original GitHub issue

I really like styled-components, it is great, thank you @mxstbr for a this module.

I’m trying to use it with react native, but cannot find a way to describe this case:

style: {
  transform: [
    { perspective: 850 },
    { translateX: - Dimensions.get('window').width * 0.24 },
    { rotateY: '60deg'},
  ],
}

export default styled.View`
  transform: ???;
`;

Is it possible? Thank you in advance.

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
JamieDixoncommented, Oct 25, 2016

In CSS I think this would look like:

perspective: 850;
transform: translateX(-123) rotateY(60deg)

Where perspective is a valid stand-alone CSS property and translateX sand rotateY are both function values that are composed with a space.

The styled-component could be: (My React Native is sketchy at best)

export default styled.View`
   perspective: 850;
   transform: translateX(-${Dimensions.get('window').width * 0.24}) rotateY(60deg);
`
2reactions
mxstbrcommented, Nov 17, 2016

Closing in favor of #210, which will add support for this!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to write styles with a deep structure in react native ...
I'm trying to use it with react native, but cannot find a way to describe this case: style: { transform: [ { perspective:...
Read more >
Organizing Styles In React Native - Revelry Labs
A useful overview of how to organize styles in React Native for improved maintenance, consistency, and organization: easy to find, ...
Read more >
Applying and Organizing Styles in React Native - Manning
From React Native in Action by Nader Dabit. This article discusses organizing styles in React Native within components.
Read more >
Styling in React: 4 ways to style a React app - LogRocket Blog
Our guide covers four popular ways to style components in React: inline styling, styled-components, CSS Modules, and Tailwind CSS.
Read more >
React Native Styling: Structure for Style Organization
1: Styles are important: make them easy to find ... Keep styles in the root source folder. Styling is a first class concern,...
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