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.

styled-components + native-base causing an error

See original GitHub issue

Hi! I am having problems using styled-components + native-base. When I try to style a native-base’s button like so:

const StyledButton = styled(Button)`margin:10;`

I get an error: “Faild prop type: Invalid props.style key ‘0’ supplied to View” This happens for any native-base component that I use. Am I doing somethink wrong here?

Issue Analytics

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

github_iconTop GitHub Comments

9reactions
mxstbrcommented, Apr 3, 2017

You need to use backticks rather than single quotes:

const StyledButton = styled(Button)`
  margin: 10;
`

That’s because styled-components uses ES6 tagged template literals. Let me know if that solves the issue!

7reactions
Charlynuxcommented, Feb 19, 2018

You should give the error message, stacktrace, …

I see two errors :

  • Typo, you write Segmeny instead of Segment
  • When you use Styled Components with external components, you must use styled as a function.
styled(Segment)`
   // your style
`

Seems more like a StackOverflow question than an issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native: `styled-components/native` cannot be resolved ...
In another terminal, yarn react-native run-ios (or use Xcode). You should see the error under the bundler session. More info of react-native ......
Read more >
FAQs - NativeBase
Solution 1: Check your rootProject name in react-native-vector-icons's font.gradle, in case if its hard coded there. This causes failure in linking ...
Read more >
Releases - styled-components
Due to our rehydration this can lead to errors, where one instance of styled-components will interfere with the other. This is why we...
Read more >
uncaught error: cannot create styled-component for ... - You.com
Description. Getting Uncaught Error: Cannot create styled-component for component: undefined after updating to latest native-base package, updated package from ...
Read more >
Error Boundaries - React
These errors were always caused by an earlier error in the application code, but React did not provide a way to handle them...
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