-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating todo list react . #18
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
function FormTodo({ addTodo }) { | ||
const [value, setValue] = React.useState(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use import {useState} from 'react';
in the top of the page.
<Card> | ||
<Card.Body> | ||
<Todo | ||
key={index} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't be using the index
of a loop as its key
in react.
https://dev.to/shiv1998/why-not-to-use-index-as-key-in-react-lists-practical-example-3e66
}, | ||
]); | ||
|
||
const addTodo = (text) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a syntactical way of improving this and avoid creating a new variable
const addTodo = (text) => { const newTodos = [...todos, { text }]; setTodos(newTodos); };
const addTodo = (text) => setTodos([...todos, { text }]);
@@ -0,0 +1,105 @@ | |||
import React from "react"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its a good practice to split the file into smaller files which contain smaller components. This way the code is readable and also maintainable.
@AnishaBheemisetty Please attach a screen shot of the UI. |
No description provided.