我是新来的react 和react 的本地人.目前,对于每个组件,我将代码分解为两个单独的文件:
-
index.js
表示所有React代码,以及; - 样式表为
styles.js
Is there a way to pass props into the external StyleSheet?
例子:
render() {
const iconColor = this.props.color || '#000';
const iconSize = this.props.size || 25;
return (
<Icon style={styles.icon} />
);
}
例styles.js
:
const styles = StyleSheet.create({
icon : {
color: iconColor,
fontSize: iconSize
}
});
上面的代码不起作用,但更多的是为了让我明白我要做的事情.非常感谢您的帮助!