我想使用 typescript 在 react-native 中制作一个可重用的组件。 大多数时候我将这种方式用作一个简单的 react-native 项目。这次我想使用 TypeScript 而不是 JavaScript。我该怎么做?
import React from 'react'
import { Text, StyleSheet, Platform } from 'react-native'
import { RFValue } from "react-native-responsive-fontsize";
const AppText = ({ children, style } ) => {
return (
<Text style={[styles.textcommon, style]} > {children} </Text>
)
}
const styles = StyleSheet.create({
textcommon: {
fontSize: RFValue(18),
alignSelf: 'center',
color: '#fff',
fontFamily: Platform.OS === 'android' ? 'Roboto-Light' : 'Avenir',
}
})
export default AppText;
答案 0 :(得分:0)
我会尝试:
const myChildWithPAssedStyle = ({ style, ...props}: {style: React.CSSProperties}) => {
}
如果您要求 React.CSSProperties
类型...