Cannot find that unexpected token is enabled (19: 9) React Native

I am following a tutorial with React Native and emulating the result using the Xcode iPhone emulator, however I am stuck in this error message and cannot see what happened. I have another file that imports this component into 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;
Run codeHide result
+4
source share
1 answer

Inside the class body, methods are declared using

render() { ... }

not

render: function() { ... }

See the MDN documentation for more information .

+11
source

Source: https://habr.com/ru/post/1608074/


All Articles