我正在用TypeScript构建一个React Native应用程序。我目前正在配置我的TSLint文件。
是否有一种方法可以在同一文档中在文件底部(导出之前)强制实施样式?
例如MyComponent.tsx
:
import React, { Component } from "react";
import { StyleSheet, Text } from "react-native";
import { SafeAreaView } from "react-navigation";
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center"
}
});
export class MyComponent extends Component {
render() {
return (
<SafeAreaView style={styles.container}>
<Text>This screen is my component.</Text>
</SafeAreaView>
);
}
}
export default MyComponent;
应该抛出一个错误,而:
import React, { Component } from 'react';
import { StyleSheet, Text } from 'react-native';
import { SafeAreaView } from 'react-navigation';
export class MyComponent extends Component {
public render() {
return (
<SafeAreaView style={styles.container}>
<Text>This screen is my component.</Text>
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
container: {
alignItems: 'center',
flex: 1,
justifyContent: 'center'
}
});
export default MyComponent;
应该通过吗?