Skip to content

Instantly share code, notes, and snippets.

@copperwall
Created March 30, 2019 15:40
Show Gist options
  • Save copperwall/e29c956dff1c0a61100610f5d6d7f879 to your computer and use it in GitHub Desktop.
Save copperwall/e29c956dff1c0a61100610f5d6d7f879 to your computer and use it in GitHub Desktop.
import React from 'react';
import FormFieldPropTypes from './FormFieldPropTypes';
import FormDefaultComponentLibrary from './FormDefaultComponentLibrary';
const FormField = ({componentLibrary, ...props}) => {
const Component = componentLibrary[props.type];
return <Component {...props} />;
}
FormField.defaultProps = {
checked: false,
componentLibrary: FormDefaultComponentLibrary,
type: 'text',
value: '',
};
FormField.propTypes = FormFieldPropTypes;
export default FormField;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment