У меня есть компонент Input
, который может иметь тему primary
или secondary
.
В настоящее время он просто меняет цвет границы:
import React from "react";
import { StyleSheet, TextInputProps, TextInput, View } from "react-native";
import Text from "./Text";
import { Colors, Theme } from "../constants";
interface Props extends TextInputProps {
label?: string,
theme?: 'primary' | 'secondary',
}
const styles = StyleSheet.create({
container: {
minHeight: 50,
marginVertical: 10,
marginHorizontal: 10,
padding: 10,
borderWidth: 1,
borderRadius: 5,
justifyContent: 'center',
},
containerPrimary: {
borderColor: Colors.primary,
},
containerSecondary: {
borderColor: Colors.secondary,
},
input: {
color: Colors.secondary,
fontSize: Theme.fontSize.base,
fontFamily: "Lato-Bold"
},
});
const Input = ({ style, theme, label, ...props }: Props) => (
<View
style={[
styles.container,
theme === 'primary' ? styles.containerPrimary : styles.containerSecondary
]}
>
{label && <Text>{label}</Text>}
<TextInput
style={[styles.input, style]}
{...props}
/>
</View>
);
Input.defaultProps = {
theme: 'primary',
}
export default Input;
Это работает, но я go на экране с использованием темы secondary
:
<Input
keyboardType="email-address"
label="E-mail :"
theme="secondary"
/>
А затем я go возвращаюсь на экран с использованием темы по умолчанию primary
:
<Input
label="Test"
/>
Граница стиля на вторичном цвете.
Что я не так сделал?