custom component theme throw error
react-native, react and native-base version
native-base: "2.0.1" query-string: "4.3.1" react: "15.4.0" react-native: "0.41.2"
Expected behaviour
expect styled component
Actual behaviour
throw error "undefined is not a function"
Steps to reproduce (code snippet or screenshot)
just try run your example
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { connectStyle } from 'native-base';
class CustomComponent extends Component {
render() {
return (
// connect styles to props.style defined by the theme
const styles = this.props.style;
<View style={styles.container}>
<Text style={styles.textContent}>
Your Component with static style
</Text>
</View>
);
}
}
const styles = {
container: {
flex: 1,
backgroundColor: 'green',
},
textContent: {
fontSize: 20,
color: 'red',
},
};
// connect the component to the theme
export default connectStyle('yourTheme.CustomComponent', styles)(CustomComponent);
Screenshot of emulator/device
https://drive.google.com/open?id=0B6--Q7UF3CaqTlp3MjFVZV9Sem8
cc @himanshu-satija
I got a problem. How to fix ???
@iambanh2 You got a problem. You should post it on Stackoverflow. If you think it is a bug with NativeBase, raise an issue here.
@kuzyk Moving the styles const out of the class should resolve your issue.