Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find what the unexpected token is on (19:9) React Native

I have been following a tutorial with React Native and emulating the result using Xcode's iPhone emulator, however I'm stuck on this error message and cannot see what's wrong. I have another file which is importing this component to be within the NavigatorIOS component.

var React = require('react-native');

var {
	View,
	StyleSheet,
	Text
} = React;

var styles = StyleSheet.create ({
	mainContainer: {
		flex: 1,
		flexDirection: 'column',
		justifyContent: 'center',
		backgroundColor: '#eee'
	}
});

class Main extends React.Component {
	render: function() {
        return (
            <Text>
            	Hello
            </Text>
        )
    }
};

module.exports = Main;
like image 278
Jonathan Lockley Avatar asked Dec 20 '22 00:12

Jonathan Lockley


1 Answers

Inside class bodies, methods are declared with

render() { ... }

not

render: function() { ... }

See the MDN documentation for more information.

like image 109
Felix Kling Avatar answered Dec 21 '22 14:12

Felix Kling