NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

custom component theme throw error

Open kuzyk opened this issue 9 years ago • 4 comments

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

kuzyk avatar Feb 07 '17 12:02 kuzyk

cc @himanshu-satija

sankhadeeproy007 avatar Feb 08 '17 14:02 sankhadeeproy007

I got a problem. How to fix ???

iambanh2 avatar Feb 13 '17 07:02 iambanh2

@iambanh2 You got a problem. You should post it on Stackoverflow. If you think it is a bug with NativeBase, raise an issue here.

sanketsahu avatar Feb 13 '17 07:02 sanketsahu

@kuzyk Moving the styles const out of the class should resolve your issue.

shivrajkumar avatar Apr 17 '17 05:04 shivrajkumar