score:0

type DataSet = {
 // write the form of state to be managed.
}

const [dataset, setDataset] = useState<DataSet>({});

score:2

interface Question {}

interface Chat {}

interface Answer { }

interface Dataset {
  answers: Array<Answer>;
  question: any;
  [k: string]: Question; 
  // ^ This signifies that Dataset can have any key as long as it's string 
  // and its value is of type Question (best I could guess based on the 
  // usage at "dataset[nextQuestionId])"
}

const App = () => {
  const [answers, setAnswers] = useState<Array<Answer>>([]);
  const [chats, setChats] = useState<Array<Chat>>([]);
  const [currentId, setCurrentId] = useState("init");
  const [dataset, setDataset] = useState<Dataset>({ answers: [], question: null });
  const [open, setOpen] = useState(false);
  // ...

Related Query

More Query from same tag