Reputation: 313
Trying to learn React Native using tutorials I'm finding on YouTube and such. However it seems like the syntax has changed greatly since the release of these tuts.
Currently I'm getting a requireTrailingComma: Missing comma before closing curly brace
error. But when I place a comma before the curly brace, it them tells me parseError Unexpected token
.
ViewContainer.js Code:
'use strict'
import { Component, View } from 'react-native';
class ViewContainer extends Component {
render() {
return (
<View style={styles.viewContainer}>
{this.props.children}
</View>
);
}
}
const styles = React.Stylesheet.create({
viewContainer: {
flex: 1,
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'stretch',
} <TIS IS WHERE I'M GETTING THE ERROR>
});
module.exports = ViewContainer;
index.ios.js Code:
'use strict'
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import ViewContainer from './app/components/ViewContainer';
class Project extends Component {
render() {
return (
<ViewContainer>
<Text>{'Hello from inside ViewContainer'}</Text>
</ViewContainer>
);
}
}
const styles = StyleSheet.create({
});
AppRegistry.registerComponent('Project', () => Project);
What am I doing wrong?
Upvotes: 1
Views: 1008
Reputation: 55750
The error says all, just put in a trailing comma after the curly brace.
alignItems: 'stretch',
}
to
alignItems: 'stretch',
},
or
alignItems: 'stretch'
}
Upvotes: 1