我在redux-form字段中使用自定义组件,如下所示.
<Field name="height" parse={value => Number(value)} component={NumberInput} />
Run Code Online (Sandbox Code Playgroud)
自定义组件使用React Native的TextInput组件,它看起来像这样:
import React from 'react';
import PropTypes from 'prop-types';
import { View, Text, TextInput, StyleSheet } from 'react-native';
import { COLOR_PRIMARY } from '../constants';
const styles = StyleSheet.create({
inputStyle: {
height: 30,
width: 50,
marginBottom: 10,
borderColor: COLOR_PRIMARY,
borderWidth: 2,
textAlign: 'center',
},
errorStyle: {
color: COLOR_PRIMARY,
},
});
const NumberInput = (props) => {
const { input: { value, onChange }, meta: { touched, error } } = …Run Code Online (Sandbox Code Playgroud) 我已将反应导航代码放入单独的 Routes 文件中,然后将其导入到 App.js 文件中。一切工作正常,但我在 Atom/Nuclide 中使用 Airbnb ESLint 配置,并收到了 TintColor 错误...
“道具验证中缺少tintColor”
尝试过这个:
Routes.propTypes = {tintColor: PropTypes.string.isRequired,}
但随后出现错误“tintColor PropType 已定义但 prop 从未使用”
这是代码的一部分
const Routes = () = {
const ContentNavigator = TabNavigator(
{
Profile: { screen: ProfileStack },
History: { screen: HistoryStack },
Questions: {
screen: QuestionsStack,
navigationOptions: {
tabBarIcon: ({ tintColor }) => (
<Icon name="question-circle" type="font-awesome" size={20} color=
{tintColor} />
),
},
},
Notifications: { screen: NotificationsStack },
},
{
initialRouteName: 'Profile',
swipeEnabled: true,
tabBarOptions: { …Run Code Online (Sandbox Code Playgroud) javascript eslint react-native react-navigation eslint-config-airbnb