The original version of this article can be found here.
I know, I know...another task app...
Hear me out though! We are going to build a task app...
For further actions, you may consider blocking this person and/or reporting abuse
Thanks for the article.
You
addItem
/removeItem
has a fairly unlikely race condition in it.You are reading the
list
from the state, modifying it, then usingthis.setState
. However,this.setState
does not update the state immediately.In theory,
addItem
could get called twice in quick succession, and you would lose one of the items added. For example with this possible ordering of events:addItem
Called with "d", modified list["a", "b", "c", "d"]
,setState
calledaddItem
called with "e", modified list["a", "b", "c", "e"]
,setState
called["a", "b", "c", "d"]
["a", "b", "c", "e"]
Just something to keep in mind.
Interesting. How would you suggest preventing that issue in a project like this?
Use call back format for setState.
Great tutorial, but why not use facebook cra instead ?
If cra is your choice, you can try c-r-a-p 💩-create-react-app-parcel 😃
I have not heard of this. It looks cool though. Thanks for the link!
It’s really personal preference, but to be honest I haven’t used create-react-app in a while and forgot it existed.
At the end It's better to make it your own way. create-react-app is for fast dev or examples but not for real projects.
That's not necessarily true. I know plenty of enterprit level projects that use React that were created with CRA. As long as you configure and secure it, it's the best solution for making a start on a React project.
I recommend you to read this article:
medium.com/@francesco.agnoletto/i-...
I couldn't disagree with this more. In a majority of cases you don't need any additional configuration.
Nice Article.
When I use getDerivedStateFromProps() in same way you use componentWillReceiveProps() in List component searching doesn't work.
static getDerivedStateFromProps(nextProps) {
return {
filtered: nextProps.items
};
}
I didn't know that getDerivedStateFromProps is called every time we setState(). Link for lifecycles projects.wojtekmaj.pl/react-lifecy....
I wanted to share this thought with you cause I didn't give enough attention about differences between componentWillReceiveProps and getDerivedStateFromProps and IMHO this is kind of important.
This is awesome! Thanks for the link!
Np. Thank you for the article
Hi there,
Really liked your tutorial Tim! <3 I thought I try all of that with functional components and this is what I got (feel free to correct me - I'm kinda rookie in webdev). Seems working though!
Minor changes I made:
used functional components instead of class components. Therefore used React.useState() for storing variables in the state.
input element for adding new todo is a controlled component and handled also in the state. Found this approach more "react-ish".
for deleting a todo I also used
filter()
method - seems more handy for me.some naming changes
App.js
List component:
default
create-react-app
index.js..."Fair warning: This part may get a bit abstract, so do your best to stick with me. If I don't explain well enough or you're struggling with it, leave a comment and I'll try to help you get it." ~ T. Smith
I love the generous spirit and the acknowledgement that sometimes what we think we're say/writing is not what is heard/understood.
There's a typo:
mkdir search-tasks && $_
should bemkdir search-tasks && cd $_
Fixed. Thank you!
Thanks for the article.
FYI, I don't see the instructions to modify the
package.json
to include thestart
script.Thanks! I have added the piece about scripts in the package.json file.
Hi Tim,
I found typo error at Next we need to install the necessary packages to our package. => Next we need to install the necessary packages to our project
Corrected. Good catch. It sounded like I was trying to be xhibit or something.
Great Article Thanks...
No problem. I’m glad it was helpful!
Hey! nice article. but how do we implement search via using two keywords. like i have rows of some information. i want to search using keywords age and gender. any idea?
how to add not found text when the user didn't find any related results?
view here - loom.com/share/59eed867b4594ace89e...
If you get an error when importing like --> import 'bulma/bulma' use --> import 'bulma/css/bulma.css'