0
invariant Violation: element type is invalid: expected a string (for built-in Components) or a class/Function (for Composite Components)but got: Undefined you likely forgot to export your Component from the file its defined in, or you Might have Mixed up default and name Imports check the render method
import React, { Component } from 'react';
import { Text, View, StyleSheet } from 'react-native';
import Button from './components/Button';
class Home extends Component {
constructor() {
super();
this.state = {
title: 'Title from state'
};
}
_onLoginPressed() {
this.props.navigation.navigate('Login');
}
render() {
return (
<View>
<Button
onPress={this._onLoginPressed.bind(this)}>
Login
</Button>
</View>
);
}
}
const styles = StyleSheet.create({
header: {
backgroundColor : '#efefef',
height: 50,
alignItems: 'center',
justifyContent: 'center',
},
text: {
fontSize: 15,
fontWeight: 'bold'
}
}
);
export default Home;
import React from 'react';
import { Touchableopacity, Text, Stylesheet } from 'React-Native';
const Button = (props) => { Return ( { props.Children } ); }
const Styles = Stylesheet.create({ button: { height: 45, borderRadius: 5, marginHorizontal: 25, marginVertical: 10, backgroundColor: 'rgb(42, 55, 68)', justifyContent: 'center', flex: 1 }, buttonText: { color: '#fff', textAlign: 'center', fontWeight: 'Bold', fontsize: 15, } });
export { Button };
Apparently the error is in the Button component (which you created?). It would be clearer if you showed his code as well.
– Junior Klawa
@Brunoborges just like Junior said, would make it easier to help your problem if you edit the question and add the component code Button you created.
– sant0will