Within the app.tsx file, I have a function that looks like this:
Since the function does not return anything, I have declared the return value as void.
const addToDo = (newToDoText: string): void => {
setToDos([...todos, { id: 4, text: newToDoText, completed: false }]);
};
I then passed this function into a form component like so:
<ToDoForm addToDo={addToDo} />
The issue arises in the ToDoForm component when I write it in this manner:
//Error Here
const ToDoForm = ({ addToDo : () => void}) => {
There are two errors - one on the closing bracket }
, which says an expression is expected, and another on the =>
arrow, which states that a semicolon is expected.
What mistake am I making here?