Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AnishaBheemisetty
Copy link
Collaborator

No description provided.

}

function FormTodo({ addTodo }) {
const [value, setValue] = React.useState("");
Copy link
Collaborator

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}
Copy link
Collaborator

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) => {
Copy link
Collaborator

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";
Copy link
Collaborator

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.

@ShashankSuresh
Copy link
Collaborator

@AnishaBheemisetty Please attach a screen shot of the UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants