From 2334d2536ff543681adb5502a2cba26e75ee34d5 Mon Sep 17 00:00:00 2001 From: michaela9 Date: Thu, 4 Apr 2024 19:58:11 +0200 Subject: [PATCH] disable button when input is empty --- src/app/components/add-item.tsx | 7 +++++-- src/app/components/button.tsx | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/components/add-item.tsx b/src/app/components/add-item.tsx index a07ad0a..026bfc4 100644 --- a/src/app/components/add-item.tsx +++ b/src/app/components/add-item.tsx @@ -1,8 +1,9 @@ 'use client'; import { useState } from 'react'; -import { Input } from './input'; + import { Button } from './button'; +import { Input } from './input'; type Props = { onAddItem: (content: string) => void; @@ -27,7 +28,9 @@ export function AddItem({ onAddItem: addItem }: Props) { onValueChange={handleOnValueChange} onEnter={handleAdd} /> - + ); } diff --git a/src/app/components/button.tsx b/src/app/components/button.tsx index 14ee322..f3a0495 100644 --- a/src/app/components/button.tsx +++ b/src/app/components/button.tsx @@ -3,10 +3,12 @@ import React from 'react'; type Props = { onClick: () => void; children: React.ReactNode; + disabled: boolean; }; -export const Button = ({ onClick, children }: Props) => ( +export const Button = ({ onClick, children, disabled }: Props) => (