Components breaks when using custom styles created by StyleSheet.create
See original GitHub issueNativeBase components, like Footer
and Content
breaks when you use the style
prop passing an object created by ReactNative StyleSheet.create
class.
I’m using the following code to reproduce the problem:
import React, { Component } from "react";
import {Container, Header, Content, Footer, Title, Button} from "native-base";
import { get as getDimension } from "Dimensions";
import {
AppRegistry,
StyleSheet,
Text,
View,
ScrollView,
} from "react-native";
class AwesomeNativeBase extends Component {
render() {
return(
<Container>
<Content>
<Text> Hello nativebase </Text>
</Content>
<Footer style={styles.footer}>
<Text> This is an awesome footer </Text>
</Footer>
</Container>
);
}
}
const styles = StyleSheet.create({
footer: {
backgroundColor: "transparent"
}
});
AppRegistry.registerComponent("AwesomeNativeBase", () => AwesomeNativeBase);
The error that I get is the following:
If I change the the Footer
as show below the component works fine.
<Footer style={{ backgroundColor: "transparent" }}>
<Text> This is an awesome footer </Text>
</Footer>
I tried to look into nativebase base but I couldn’t find exactly why this hapen but I guess this is related to this nativebase file and this React Native breaking change: StyleSheetRegistry has been renamed to ReactNativePropRegistry. This module is private so it shouldn't affect everyone using React Native's public API, though: 433fb33
, this breaking change can be found on this React Native release note.
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:21 (4 by maintainers)
Top Results From Across the Web
StyleSheet.create() inside React Native component
So that way you keep your styles object outside of the component, and they are not newly-created on each re-render. Share.
Read more >StyleSheet - React Native
A StyleSheet is an abstraction similar to CSS StyleSheets. ... Naming the styles is a good way to add meaning to the low...
Read more >Solving the React Error: Not Picking Up CSS Style | Pluralsight
In this guide, you will learn about the errors that can occur while importing a CSS file into your React file.
Read more >How To Style React Components | DigitalOcean
In this tutorial, you'll learn three different ways to style React components: plain Cascading Style Sheets (CSS), inline styles with JavaScript ...
Read more >Styling // React Native for Web - GitHub Pages
Style performance is improved when styles are defined outside of components using the StyleSheet API. This creates opaque references to the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
+1 for this. You can solve this issue by flatten the style object like this:
@sanketsahusoft Please do so, it’s very annoying to have to see which library we’re importing components from to decide how we’re going to create style objects.