import PropTypes from 'prop-types'; import { View, Text } from 'react-native'; import React from 'react'; import TypeMap from './types'; const InvalidType = () => Invalid Type; const PropField = ({ onChange, onPress, knob }) => { const InputType = TypeMap[knob.type] || InvalidType; return ( {!knob.hideLabel ? ( {`${knob.label || knob.name}`} ) : null} ); }; PropField.propTypes = { knob: PropTypes.shape({ name: PropTypes.string, label: PropTypes.string, value: PropTypes.any, hideLabel: PropTypes.bool, type: PropTypes.oneOf([ 'text', 'number', 'color', 'boolean', 'object', 'select', 'array', 'date', 'button', ]), }).isRequired, onChange: PropTypes.func.isRequired, onPress: PropTypes.func.isRequired, }; export default PropField;