-1

I am trying to copy a react todo list from youtube but i cant understand why i am getting this error in the console. I am following along with the video i am new to this so i am not to sure what the problem is exactly but i know i cant follow the video anymore because i get this error in the console.console

App.js
 import React, { useState } from 'react';
import './App.css';
import TodoList from './components/TodoList';

function App() {
  return (

<div className='todo-app'>
 <TodoList />



</div>
  );
}

export default App;

TodoForm.js
import React, {useState} from 'react'

function TodoForm(props) {
    const {input, setInput} =useState('');

    const handleChange = e => {
        setInput(e.target.value);
    };

    const handleSubmit = e => {
        e.preventDefault();

        props.onSubmit({
        id: Math.floor(Math.random() * 10000),
        text: input
        });

      setInput('');
    };

  return ( 
   <form className='todo-form' onSubmit={handleSubmit}>
    <input type='text' placeholder='Add a todo' value={input} name='text'className='todo-input' onChange={handleChange} />
    <button className='todo-input'>Add todo</button>

   </form>
  )
}

export default TodoForm

I tried figuring this by googling it but no luck iam not to sure how to go about this?

1 Answers1

0

replace this

const {input, setInput} =useState('');

with this

const [input, setInput] =useState('');
Sachila Ranawaka
  • 39,756
  • 7
  • 56
  • 80