import React, {useState} from "react"; import QuestionItem from "../QuestionItem/QuestionItem.tsx"; import AddQuestionButton from "../AddQuestionButton/AddQuestionButton.tsx"; interface QuestionsListProps {} interface Question { id: number; } const QuestionsList: React.FC = () => { const [questions, setQuestions] = useState([ {id: 1}, ]); const handleAddQuestion = () => { // Find the highest ID in the current questions list const maxId = questions.reduce((max, question) => Math.max(max, question.id), 0); const newQuestion: Question = { id: maxId + 1, // Increment the ID }; setQuestions([...questions, newQuestion]); // Add the new question to the state }; return ( <> {questions.map((question, index) => ( ))} ); }; export default QuestionsList;