diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
| commit | f861e6a269ba9f62700776d3cd13b644a9e836d4 (patch) | |
| tree | a5a107e7a6e4ff8b4261fe04349357bc00b783ee /src/components/atoms/forms/field.tsx | |
| parent | 03331c44276ec56e9f235e4d5ee75030455a753f (diff) | |
refactor: use named export for everything except pages
Next expect a default export for pages so only those components should
use default exports. Everything else should use named exports to
reduce the number of import statements.
Diffstat (limited to 'src/components/atoms/forms/field.tsx')
| -rw-r--r-- | src/components/atoms/forms/field.tsx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/components/atoms/forms/field.tsx b/src/components/atoms/forms/field.tsx index 377e1b0..a4553e3 100644 --- a/src/components/atoms/forms/field.tsx +++ b/src/components/atoms/forms/field.tsx @@ -72,12 +72,7 @@ export type FieldProps = { value: string; }; -/** - * Field component. - * - * Render either an input or a textarea. - */ -const Field: ForwardRefRenderFunction<HTMLInputElement, FieldProps> = ( +const FieldWithRef: ForwardRefRenderFunction<HTMLInputElement, FieldProps> = ( { className = '', setValue, type, ...props }, ref ) => { @@ -93,19 +88,24 @@ const Field: ForwardRefRenderFunction<HTMLInputElement, FieldProps> = ( return type === 'textarea' ? ( <textarea - onChange={updateValue} - className={`${styles.field} ${styles['field--textarea']} ${className}`} {...props} + className={`${styles.field} ${styles['field--textarea']} ${className}`} + onChange={updateValue} /> ) : ( <input + {...props} className={`${styles.field} ${className}`} onChange={updateValue} ref={ref} type={type} - {...props} /> ); }; -export default forwardRef(Field); +/** + * Field component. + * + * Render either an input or a textarea. + */ +export const Field = forwardRef(FieldWithRef); |
