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.

no-raw-text doesn't work for custom styled components

See original GitHub issue

Unless I’m doing something wrong, the no-raw-text rule doesn’t seem to work when using styled-components. This makes it largely useless I think? Would be nice to be able to use this rule but not sure how to do so when using styled-components.

import styled from 'styled-components/native';

let view = () => (
  <MyText>This doesn't work</MyText>
);

const MyText = styled(Text)`
  font-size: 16;
`;

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:12
  • Comments:10

github_iconTop GitHub Comments

6reactions
mattpetriecommented, Aug 12, 2020

Also running into this. One possible option to fix it would be to change the skip option to accept a regex instead of (or in addition to) an array of strings, so that you could do, for example:

'react-native/no-raw-text': ['error', {skip: '/Text$/'}]

to skip any component that is suffixed with Text.

3reactions
LauraBeatriscommented, Jul 25, 2020

Same problem… My codebase is using a lot of Typograph components made with styled-components and unfortunately, I had to disable this rule

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extending styles with styled-components not working
The styled method works perfectly on all of your own or any third-party components, as long as they attach the passed className prop...
Read more >
FAQs - styled-components
Commonly asked questions about styled-components.
Read more >
Style your React Components like a Boss with ... - Codementor
styled -components exposes a React Context that works wonderfully with every component you build. You can create a theme object and use it ......
Read more >
Demystifying styled-components - Josh W Comeau
In this post, we'll learn exactly how styled-components works by building ... You don't need to understand how cars work in order to...
Read more >
How to use styled-components with React Native
styled -components is a CSS-in-JS library that is open source and allows you, ... Creating custom components in any React or React Native...
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