React Todo List App Tutorial - Beginner React JS Project Using Hooks
HTML-код
- Опубликовано: 16 май 2024
- Learn how to build a React Todo List App in this beginner project tutorial. We will mainly use React hooks, so useEffect, useState, and useRef. You will be able to add, remove, edit, and mark complete/cross out the todo items.
If you want to follow me along my coding journey, be sure to subscribe :)
/ @briandesign
Timeline:
0:00 React Todo App Intro
1:46 Creating React App in Terminal
5:26 Creating the Components
6:41 Editing TodoForm Component
15:00 Editing TodoList Component
22:20 Editing the Todo Component
42:50 Adding the CSS
45:50 Creating Custom Edit Input
Source code
github.com/briancodex/react-t...
Responsive React Website Tutorial
• React Website Responsi...
After i tried following the video, i just realized this is not for beginner.
But it's good.
Me: beginner react
Yeah, same here. I copied and tryed to understand the code in the process but it's quite difficult for a newbie.
Yes he wrote all methods and state from the beginning itself then only he handle the input field but still we can understand if we have lil konowledge about react
@@asifck439 actually there are lots of things going on which are connected with each other but he wrote the things first which comes in last
css for near the end of the tutorial:
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande',
'Lucida Sans', Arial, sans-serif;
}
body {
background: linear-gradient(
90deg,
rgba(48, 16, 255, 1) 0%,
rgba(100, 115, 255, 1) 100%
);
}
.todo-app {
display: flex;
flex-direction: column;
justify-content: start;
width: 520px;
min-height: 600px;
background: #161a2b;
text-align: center;
margin: 128px auto;
border-radius: 10px;
padding-bottom: 32px;
}
h1 {
margin: 32px 0;
color: #fff;
font-size: 24px;
}
.complete {
text-decoration: line-through;
opacity: 0.4;
}
.todo-form {
margin-bottom: 32px;
}
.todo-input {
padding: 14px 32px 14px 16px;
border-radius: 4px 0 0 4px;
border: 2px solid #5d0cff;
outline: none;
width: 320px;
background: transparent;
color: #fff;
}
.todo-input::placeholder {
color: #e2e2e2;
}
.todo-button {
padding: 16px;
border: none;
border-radius: 0 4px 4px 0;
cursor: pointer;
outline: none;
background: linear-gradient(
90deg,
rgba(93, 12, 255, 1) 0%,
rgba(155, 0, 250, 1) 100%
);
color: #fff;
text-transform: capitalize;
}
.todo-input.edit {
border: 2px solid #149fff;
}
.todo-button.edit {
background: linear-gradient(
90deg,
rgba(20, 159, 255, 1) 0%,
rgba(17, 122, 255, 1) 100%
);
padding: 16px 22px;
}
.todo-container {
display: flex;
flex-direction: row;
position: relative;
}
.todo-row {
display: flex;
justify-content: space-between;
align-items: center;
margin: 4px auto;
color: #fff;
background: linear-gradient(
90deg,
rgba(255, 118, 20, 1) 0%,
rgba(255, 84, 17, 1) 100%
);
padding: 16px;
border-radius: 5px;
width: 90%;
}
.todo-row:nth-child(4n + 1) {
background: linear-gradient(
90deg,
rgba(93, 12, 255, 1) 0%,
rgba(155, 0, 250, 1) 100%
);
}
.todo-row:nth-child(4n + 2) {
background: linear-gradient(
90deg,
rgba(255, 12, 241, 1) 0%,
rgba(250, 0, 135, 1) 100%
);
}
.todo-row:nth-child(4n + 3) {
background: linear-gradient(
90deg,
rgba(20, 159, 255, 1) 0%,
rgba(17, 122, 255, 1) 100%
);
}
.icons {
display: flex;
align-items: center;
font-size: 24px;
cursor: pointer;
}
.delete-icon {
margin-right: 5px;
color: #fff;
}
.edit-icon {
color: #fff;
}
at 20.00 mnt, im stuck beacuse error. and after checked in console have notice :
react-dom.development.js:86 Warning: You passed a container to the second argument of root.render(...). You don't need to pass it again since you already passed it to create the root.
any one have solutiion?
Luckily I wasn't completely new to React because in all honesty this wasn't a very well planned out tutorial for beginners.
From a learning perspective, it was hard to follow as you declared functions several times before they were written.
It probably does make complete sense to someone well versed in React because you can do them in whatever order (as you know how to tie them up ultimately) but as a novice, it's hard to follow and understand.
However that criticism aside, I really enjoyed making this application and have subbed for more.
Thanks for saving my
50 minutes :)
Nah he just doesn't know what he's doing. It's easier to make a RUclips channel and pretend you know how to code than it is to just learn to code and get a job...
I see it ALL the time.
@@MM-lo9tk Lol chill out bro, he is on a "coding journey", learning by teaching. Haters gonna hate.
agreed, he really didnt make it beginner friendly. For sure should not decalre things before he even writes them. was confused for so much of it. I think he needs to redo the video, and do one step at a time.
im on you
When I was looking for React tutorials, everyone was throwing shade at To Do apps. You made a great tutorial and I learned a lot! Thanks.
Awesome, thank you!
Master! This video answered all the questions I was having with React! Thank you!
your are just typing the code, please try to explain what does those function do. so that it will be easy to understand.
Excellent tutorial!! Thanks for all the hard work. Love your entire channel
I noticed a few comments in here that are critical but respectful and hit on a crucial point for your channels content in general - the things you create are amazing, elegant, and beautiful, but the way you explain them is not very effective. The order in which you do things is perhaps convenient based on the template you've created, but from a learning perspective it's hard to see what's going on let alone draw those necessary correlations. I'm familiar with React, so I can see what's going on, but that only makes it clearer how strange the approach to some of these things is.
That being said, I only take the time to write this comment because I love the concept of your channel, your developments are beautiful, and you're a cool dude so I'd love to see you get more views and subs. I'd also love to be able to use your videos to learn more!
Thanks man. I wanted to get a project done in react before moving on to learning back-end stuff. This got me there, will have some fun playing about with the CSS tomorrow!
at 20.00 mnt, im stuck beacuse error. and after checked in console have notice :
react-dom.development.js:86 Warning: You passed a container to the second argument of root.render(...). You don't need to pass it again since you already passed it to create the root.
any one have solutiion?
thanks for this great tuturial. i needed a toturial like this to have a good training project and really enjoyed of coding this app . i'll follow the entire of your channel bro ;)
Thank you for the starter project that I worked on
beautiful! I loved the tutorial! I learned so much!
This was a great app. Local storage add on would be nice with this app.
Great tutorial ! I learned a lot, thank you for taking the time to make this I found it very helpful!!
Thank you so much for this brilliant tutorial, I had not a clue about react before today. I still have a long way to go but feel confident I can get there from this tutorial. Clear, concise, transparent and fun. Genuine thanks.
Great tutorial! You taught me code and a great attitude. Excellent instructions, thanks!
banger as always. Keep it up!
Sos un grande amigo, gracias por subir este contenido!!
Brian thanks alot for put some effort and time to make a tutorial for people, I really appreciate, one that I need to mention is that since you have already mastered react, it's so easy for you to understand why you are doing something as simple as writing some thing to fix the button which refresh the page instead of send some information, but for me as a beginner, it's so hard to decode what you wrote there, as I need to understand how would that send information to database or something.
So please keep your cool work up, and add some more details
at 20.00 mnt, im stuck beacuse error. and after checked in console have notice :
react-dom.development.js:86 Warning: You passed a container to the second argument of root.render(...). You don't need to pass it again since you already passed it to create the root.
any one have solutiion?
Dude you are the best man. I dig your videos
You saved my life, thank you!
works perfect, I definitely subscribed...thanks!!!!
thanks for this video. I've been learning & coding in JavaScript since January and although it took me 2 days, I was able to build my first app.
at 20.00 mnt, im stuck beacuse error. and after checked in console have notice :
react-dom.development.js:86 Warning: You passed a container to the second argument of root.render(...). You don't need to pass it again since you already passed it to create the root.
any one have solutiion?
Thank you so much for this tutorial. I helps a LOOOT of people with their developing careers including me as an intermediate learner. Keep on uploading :)
This was great. tysm
Thanks a lot.
❤
Thank you very much, my friend! I think this world is getting better thanks to you!! )
Not for absolute beginners but its a good video in order to get an idea of what's going on.
Again good tutorial. One request is that while using any inbuild function, feature from react for example useEffect method then please explain its significance and why we should use it if time permits. This can clear React fundamentals as well.
I agree
Brian Design - Thank you so much for this tutorial. It is really helpful.
by help of this extensively great tutorial i fixed my whole problms thanks very much
Glad it helped
Super Thanks bro!
Man thank you for this.
thanks dude im always learning more!!
Glad to hear it!
Fire. Not for the true beginners, but it was a good struggle and learning experience for a lvl 3 like me.
it was light work for a guy like me (mentally unstable)
Thank you so much!
You did a great job!
I wish you health and success!!!
With love from Ukraine :)
hope you're safe amidst the crisis? :)
The reason why console.log(...todos) not printing the latest added element is because setTodos is setting the value to todos. React doesn't immediately do that and it also takes a callback. So, javascript generally doesn't wait the setTodos to finish its work and console the items it have on todos. React plans out the re-rendering of the component when the state is updated. It doesn't do that immediately.
most excellent my dude
Good day! Could you tell me how to bind each input to the list of elements, and when entering text into an input, it would be displayed in the line below the element ?
I am having an issue and I want to know if this is just a limitation of the way its programmed or if i messed up. When editing a todo and then submitting the edit. the content of the other edits disappear. Any fixes?
keep going bro, great tutorial
Thanks!
superb tutorial. works great
AMAZING Rich!
Superb Brian..... Keep it up :)
Thank you so much sir ❤️
thanks for make this video im do excited when I learn it with your video, I like your explaintation.
Thanks dude , keep going !
Thanks Mohammed!
great beginner tut for the todo in react!
thank you, master!
Great vid helped a lot!
Great tutorial ! I learned a lot, thanks for share this video
at 20.00 mnt, im stuck beacuse error. and after checked in console have notice :
react-dom.development.js:86 Warning: You passed a container to the second argument of root.render(...). You don't need to pass it again since you already passed it to create the root.
any one have solutiion?
Tks man, u help me so much!
Good Project Thanks..🤓
This app shows the importance of having a centralized state , the prop drilling is serious here
Exactly, and it's not really helpful that functions are declared before he actually writes the functionality for the function.
@@elliottarnold9542 yeah, its creating a lot of confusion
@@laturchasanket6901 It happens on his videos. He just needs to commit to one thing at a time; he assumes we already have the end in mind as he does since he is the creator. When someone is coding along, the process needs to be linear.
@@elliottarnold9542 Exactly! Nice catch.
Awesome Tutorial!
Awesome video, but if i would like to shared the value of the input with another component how do i do?, with redux {dispatcher, etc}?
have issue in the minit 32
cant add item in the fields ??
any help please ?
Thank you. It was very good. I wish you success
Awsome, subbed.
can you make a number guessing game in React js as well? with reset, clear and submit button, or how many attempts are left?
Great video, thanks bro 👏👏👏👏
Thanks!
Really helpful , nice UI
Setting Id incrementally, zero to infinite instead of having random number in a range:
const [id, setId] = useState(0);
const giveId=()=>{
setId(id + 1)
return id;
}
const handleSubmit = (e)=> {
e.preventDefault();
props.onSubmit({
id: giveId(),
text:input
});
setInput("");
};
at 20.00 mnt, im stuck beacuse error. and after checked in console have notice :
react-dom.development.js:86 Warning: You passed a container to the second argument of root.render(...). You don't need to pass it again since you already passed it to create the root.
any one have solutiion?
which extensions are in use during this tutorial? which one autofills the html tags and which extension organised the code in the input tag for you?
@Brian Design using icons making the output not to render on browser
even after insta;;ing the packages also
Thank you so much. What is them you used?
You Rock!
Thank you so much!
Help Please !!! I am getting Error
TypeError: Cannot read property 'map' of undefined
Hey dude, thanks you for share your knowledge
Thanks Yuri!
thanks for the tutorial. i can see your variable params are set to a redish pinkish color. Can you teach me how to set those changes? I tried tokencolorcustomization but it seems to highlight other variables too :'(
So glad i came across your channel, this was a great tutorial! Would it be possible to create a part 2 to this? i'd love to learn how you'd store the to-do list data so that it doesn't clear out on refreshes, perhaps using firebase realtime database?
Hey, thanks for commenting! So you could implement localstorage to save the data, but firebase would prob be better since it's saved there. There's plenty of other todo app tutorials I've seen where they implement firebase/local storage that you could simply add to the code I made for this app if you wanted to do it now.
I'll most likely update all my projects with firebase or backend in the future, but for now you could probably find a few resources to get started on youtube
Can you please share me the source code please? Iam stuck with an error props.submit is not a function.
I just started learning react, and i learn so much from you, are you going to make a crud project using react and firebase?
Ill make one in the future once I have more time
what is your icon Theme Extension pls show Tell Me
Could you do a follow up tutorial on how to persist this To do list to a database?
which font family are you using in VS,Brian
I have a question...
const submitUpdate = value => {
updateTodo(edit.id, value);
setEdit({
id: null,
value: ''
});
};
if (edit.id) {
return ;
}
but you didint give any parameter for submitUpdate Function. how it take its value to update?
i would have loved to see a save feature i would have used this for my everyday needs
thank you :)
Question: How does submitUpdate get a value passed to it? When we call submitUpdate when don't pass a value as an argument.
How do you gave addTodo the parameter value of todo and then used todo.text
is it coming from the child component cause you haven't returned any value from there.
correct me if I'm wrong
Thanks for the tutorial. For newbies out there like me looking to clone, the public folder and index.html is not included so you will get errors with npm. :) Just thought Id mention that.
Yep!
rfce to create a component ?
how come no one told me that before , cool extension!!
Can someone explain to me on 37:37
- what is that 'prev' variable in the setTodos ? if I put a function in it with parameter, the parameter will be the entire todos?
also, how does the second form [when editing] disappear after submiting? the first one always stays so why does the other one just disappear? [asking code wise, I understand why it's gone - its only for edit]
tnx
Awesome videos it helps me alot
Thanks for the tutorial.....Can you help me with one more thing.....How to store the same code in local storage so that whenever the browser is refreshed the list remains. Thanks in advance.
Hi Brian, thanks for the great tutorial, your react website tutorials are some of the best on RUclips. I've completed this successfully but there's a strange behavior I noticed on both yours and my own that I couldn't figure out. Considering we log the todos after every submission, why does the first not show when we click add for the first time? They always seem a task behind in the log? Strange stuff.
hmm I'll have to check that out. If you find a solution, feel free to let me know
@@briandesign Lol just figured it out via of course StackOverflow. It's due to useState not being synchronous. Not sure if links are permitted in your comment section but I'll leave this here should you be interested, or be it useful to anyone else: stackoverflow.com/questions/28773839/react-form-onchange-setstate-one-step-behind.
stackoverflow saving the day haha. I'll check that post out! Thanks for sharing Keelan
Thanks for this tutorial Brian, incredibly helpful. Could I ask what theme in vsCode are you using?
CSS File to save you all time.
{
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande',
'Lucida Sans', Arial, sans-serif;
}
body {
background: linear-gradient(
90deg,
rgba(48, 16, 255, 1) 0%,
rgba(100, 115, 255, 1) 100%
);
}
.todo-app {
display: flex;
flex-direction: column;
justify-content: start;
width: 520px;
min-height: 600px;
background: #161a2b;
text-align: center;
margin: 128px auto;
border-radius: 10px;
padding-bottom: 32px;
}
h1 {
margin: 32px 0;
color: #fff;
font-size: 24px;
}
.complete {
text-decoration: line-through;
opacity: 0.4;
}
.todo-form {
margin-bottom: 32px;
}
.todo-input {
padding: 14px 32px 14px 16px;
border-radius: 4px 0 0 4px;
border: 2px solid #5d0cff;
outline: none;
width: 320px;
background: transparent;
color: #fff;
}
.todo-input::placeholder {
color: #e2e2e2;
}
.todo-button {
padding: 16px;
border: none;
border-radius: 0 4px 4px 0;
cursor: pointer;
outline: none;
background: linear-gradient(
90deg,
rgba(93, 12, 255, 1) 0%,
rgba(155, 0, 250, 1) 100%
);
color: #fff;
text-transform: capitalize;
}
.todo-input.edit {
border: 2px solid #149fff;
}
.todo-button.edit {
background: linear-gradient(
90deg,
rgba(20, 159, 255, 1) 0%,
rgba(17, 122, 255, 1) 100%
);
padding: 16px 22px;
}
.todo-container {
display: flex;
flex-direction: row;
position: relative;
}
.todo-row {
display: flex;
justify-content: space-between;
align-items: center;
margin: 4px auto;
color: #fff;
background: linear-gradient(
90deg,
rgba(255, 118, 20, 1) 0%,
rgba(255, 84, 17, 1) 100%
);
padding: 16px;
border-radius: 5px;
width: 90%;
}
.todo-row:nth-child(4n + 1) {
background: linear-gradient(
90deg,
rgba(93, 12, 255, 1) 0%,
rgba(155, 0, 250, 1) 100%
);
}
.todo-row:nth-child(4n + 2) {
background: linear-gradient(
90deg,
rgba(255, 12, 241, 1) 0%,
rgba(250, 0, 135, 1) 100%
);
}
.todo-row:nth-child(4n + 3) {
background: linear-gradient(
90deg,
rgba(20, 159, 255, 1) 0%,
rgba(17, 122, 255, 1) 100%
);
}
.icons {
display: flex;
align-items: center;
font-size: 24px;
cursor: pointer;
}
.delete-icon {
margin-right: 5px;
color: #fff;
}
.edit-icon {
color: #fff;
}
Sir please help me to understand where the isComplete boolean is from, thank you
I created but when I am going with edit button it's editing options is coming but when I edit and add again edit showing error :- props.onSubmit is not a function iside TodoForm ????? Please resolve as soon I'm stuck in last minute 🙄
i see your all videos AND i like your videos
Where did the props.edit come from in TodoForm? I don't see that props passed in the ToDoList component
When we update the to-do item, the text gets changed but the id for that item is set to NaN. Is there any way to tackle this?
Can someone explain the todo.isComplete I didn't get where did we declared its initial value??
Thank you!
wrote code like u and got error Uncaught TypeError: Cannot read properties of undefined (reading 'text') in props.onSubmit.
Please help!
19:44 cant get passed this, the console throws me this error "Warning: Expected `onSubmit` listener to be a function, instead got a value of `string` type"
also the e.preventDefault method didnt prevented the from reloading
how did you italized the className, type, value etc.?
thanks a lot !
Your text looks awesome. Which theme you use ? plz say , , , , ,,
at 24:35 ,You said "to check if todo is completed or not", i don't know what that means, what is completed or not?