How to display the data on the page React JS?

import React { useState } from 'react';
import { Form, Input, Button, Card } from 'antd';
import style from '../../index.scss';

const App = () => {

const [todos, setTodos] = useState(");



const onFinish = values => {
 const newTodoItem = {title: values.todoTitle, complete: false}
 const newTodos = [...todos, newTodoItem]
setTodos(newTodos)
console.log(newTodoItem)
}

 return (
<>
 <h1 className={style.title}>To-Do</h1>
the <div>
<Form
name="basic"
onFinish={onFinish}
 style={{ width: 200 }}
>
<Form>.Item
name="todoTitle"
>
 <Input />
</Form.Item>

<Form>.Item>
 <Button type="primary" htmlType="submit">
Add
</Button>
</Form.Item>
</Form>
</div>
the <ul><li>oooo</li></ul>
</>
);
};

export default App;
Good day, tell me how to display the data on the page function onFinish I get a new todo items but as they trendit I don't understand, can someone explain and suggest what to read ?
April 19th 20 at 12:22
1 answer
April 19th 20 at 12:24
Solution
TypeError: todos.map is not a function - edgar69 commented on April 19th 20 at 12:27
@edgar69, see if the map method your todos - Stanton_Wiega commented on April 19th 20 at 12:30
@Stanton_Wiega, all of the component , I posted on the question of what it means to see if the map method? - edgar69 commented on April 19th 20 at 12:33
@edgar69,
That's correct
const [todos, setTodos] = useState(");
it
const [todos, setTodos] = useState([]);
You initialize the array string. - demetris90 commented on April 19th 20 at 12:36
@demetris90,
×
Error: Objects are not valid as a child React (found: object with keys {title, complete}). If you meant to render a collection of children, use an array instead.
it's a goddamn todo that I tried to frame index but it's not working , maybe you need to write a function which will render the id ? - edgar69 commented on April 19th 20 at 12:39
@edgar69, you can try todo.title if they are different or to normalize the array.
https://ru.reactjs.org/docs/lists-and-keys.html - demetris90 commented on April 19th 20 at 12:42
@demetris90, Thanks for the help, I will understand - edgar69 commented on April 19th 20 at 12:45
@demetris90, if you modify the row with an initial state that swears by setTodos(newTodos)
×
Error: Objects are not valid as a child React (found: object with keys {title, complete}). If you meant to render a collection of children, use an array instead. - edgar69 commented on April 19th 20 at 12:48

Find more questions by tags React